hduoj1060(Leftmost Digit)
2015-03-06 16:29
183 查看
Leftmost Digit
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 14145 Accepted Submission(s): 5413 [align=left]Problem Description[/align]Given a positive integer N, you should output the leftmost digit of N^N. [align=left]Input[/align]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). [align=left]Output[/align]For each test case, you should output the leftmost digit of N^N. [align=left]Sample Input[/align]2 3 4
[align=left]Sample Output[/align]
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.
#include<stdio.h> #include<math.h> int main() { int n; __int64 m,s; double a; scanf("%d",&n); while(n--) { scanf("%I64d",&m); a=m*(log(m)/log(10)); a-=(__int64)a; s=(__int64)pow(10.0,a); printf("%I64d\n",s); } return 0; }
相关文章推荐
- (HDOJ 1060)Leftmost Digit
- HDOJ-1060-Leftmost Digit(求n^n的最高位)
- HDOJ1060 Leftmost Digit(求n^n的最高位)
- hdu 1060 - Leftmost Digit(求N^N最高位)
- HDU 1060 Leftmost Digit(求n^n的最左位)
- HDU-1060-Leftmost Digit
- HDU 1060 Leftmost Digit
- HDU 1060 Left-most Digit
- HDOJ-1060-Leftmost Digit(求n^n的最高位)
- HDOJ-1060-Leftmost Digit(求n^n的最高位)
- hdu 1060 Leftmost Digit
- Leftmost Digit(杭电1060)(求N^N的最高位)
- HDU 1060 Leftmost Digit(求 n ^ n 的最高位的值)
- hdu1060 Leftmost Digit
- HDU--1060--Leftmost Digit
- HDU 1060 LeftMost Digit
- 杭电ACM1060——Leftmost Digit
- hdu1060 Leftmost Digit
- HUD-1060 Leftmost Digit
- hdu 1060 the leftmost digit 计算N^N最左面的一位数