hdu 1060 Leftmost Digit
来源:互联网 发布:kinyo lolita淘宝店铺 编辑:程序博客网 时间:2024/05/29 03:27
m=n^n;两边同取对数,得到,log10(m)=n*log10(n);再得到,m=10^(n*log10(n));然后,对于10的整数次幂,第一位是1,所以,第一位数取决于n*log10(n)的小数部分
Leftmost Digit
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 13967 Accepted Submission(s): 5339Problem DescriptionGiven a positive integer N, you should output the leftmost digit of N^N.InputThe 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).OutputFor each test case, you should output the leftmost digit of N^N.Sample Input234Sample Output22HintIn 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.AuthorIgnatius.L代码:
#include <stdio.h>#include <math.h>int main(){ double test; double a; double c; __int64 b; __int64 d; int n; scanf("%d",&n); while(n--) { scanf("%lf",&test); a=test*log10(test); b=(__int64)a; c=a-b; d=(__int64)(pow(10,c)); printf("%I64d\n",d); } return 0;}
0 0
- HDU 1060 Leftmost Digit & BIT1046 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
- 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
- HDU 1060 Leftmost Digit
- HDU-1060 Leftmost Digit
- hdu 1060 Leftmost Digit
- 如何删除iTunes Connect里已经上架的应用
- HDOJ-1920-Jackpot 解题报告
- Request和Session的区别
- 初音未来好听的歌
- Android - 文件操作 小结
- hdu 1060 Leftmost Digit
- eclipse 更换jdk版本后,工程出现红色感叹号 解决办法
- win7删除多余开机启动菜单的方法(图文)
- 横竖折对称方正
- 项目管理包括哪些过程?
- easyUI分页
- Android多分辨率适配总结
- Linux内核学习之系统调用
- 区间dp