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的整数部分就是这个数的最左边的那一位; 对两边取对数 num*log10(num)= n+lg(a);n+lg(a)这个数中,n肯定是个整数,lg(a)肯定是个小数; 代码:
|
相关文章
- Leftmost Digit(hdu1060)(数学题)
- hdu1060 Leftmost Digit---求N的N次方的首位(对数)
- CF715C:Digit Tree
- Kaggle—Digit Recognizer竞赛
- HDU1061-Rightmost Digit(高速功率模)
- Specialized Four-Digit Numbers
- 欧拉工程第63题:Powerful digit counts
- [Find the last digit when factorial of A divides factorial of B]
- HDU 1061 Rightmost Digit解决问题的方法
- 2018.09.17 atcoder Digit Sum(数论)