Leftmost Digit
Problem Description
Given a positive integer N, you should
output the leftmost digit of N^N.
|
Input
The input contains several test cases.
The first line of the input is a single integer T which is the
number of test cases. T test cases follow.
Each test case contains a single positive integer N(1<=N<=1,000,000,000). |
Output
For each test case, you should output
the leftmost digit of N^N.
|
Sample Input
2 3 4 |
Sample Output
2 2 Hint In the first case, 3 * 3 * 3 = 27, so the leftmost digit is 2. In the second case, 4 * 4 * 4 * 4 = 256, so the leftmost digit is 2. 题意:给你一个数n让你求n^n最高位的数; 解题思路:那天上午在实验室写了这个题,刚开始看到数很大就寻思找规律,结果输出不到20位,数就太大了,回来之后想了好几天,后来又借鉴了大神的思路,知道了。 num^num=10^n*a;a的整数部分就是这个数的最左边的那一位; 代码:
|
我每天都在努力,只是想证明我是认真的活着.