1060—Leftmost Digit
2013-05-05 21:29
232 查看
题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=1060
收获:计算N^N结果的最左边的数
由sum=N^N,两边对10取对数,log10(sum)=Nlog10(N),有sum=10^(Nlog10(N));
sum=10^(整数+小数)=10^整数*10^小数;
由于10的整数次幂首位均为1,则仅需考虑Nlog10(N)的结果的小数部分,取整即为最左边的数
int n;
double k=(double)n;
我的代码:
收获:计算N^N结果的最左边的数
由sum=N^N,两边对10取对数,log10(sum)=Nlog10(N),有sum=10^(Nlog10(N));
sum=10^(整数+小数)=10^整数*10^小数;
由于10的整数次幂首位均为1,则仅需考虑Nlog10(N)的结果的小数部分,取整即为最左边的数
int n;
double k=(double)n;
我的代码:
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<math.h> int main() {int t; __int64 n; scanf("%d",&t); while(t--) {scanf("%I64d",&n); int uu; uu=(int)pow(10.0,n*log10((double)n)-(__int64)(n*log10((double)n))); printf("%d\n",uu); } return 0; }
相关文章推荐
- HDU 1060 Leftmost Digit
- HDU-1060 Leftmost Digit (数学)
- HDOJ 1060 Leftmost Digit
- HDU 1060 Leftmost Digit
- 【杭电】[1060]Leftmost Digit
- HDU - 1060 Leftmost Digit (数学取对数)规律
- hdu 1060 Leftmost Digit
- HDU 1060 Leftmost Digit
- HDU 1060 - Leftmost Digit
- HDU 1060 Leftmost Digit(数论)
- hdu 1060 Leftmost Digit
- HDU 1060 Leftmost Digit (数学log)
- HDU1060 Leftmost Digit (数学推导)
- hdu 1060 Leftmost Digit
- hdu/hdoj 1060 Leftmost Digit
- HDU 1060 - Leftmost Digit
- HDU 1060 Leftmost Digit
- HDU 1060 Leftmost Digit
- hdu 1060 Leftmost Digit
- hdu 1060 Leftmost Digit