http://acm.hdu.edu.cn/showproblem.php?pid=1060
2012-03-22 09:14
316 查看
Leftmost Digit
[b]Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7028 Accepted Submission(s): 2703
[/b]
[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
AC代码:
#include<iostream> #include<cmath> using namespace std; int main() { int T; cin>>T; while(T--) { long long n; cin>>n; double k=n*log10(double(n)); k=k-(long long )k;//注意这里应是1long long 类型 k=pow(10.0,k); while(k<1) k*=10; cout<<(int)k<<endl; }return 0; }
相关文章推荐
- Quoit Design&&http://acm.hdu.edu.cn/showproblem.php?pid=1007
- http://acm.hdu.edu.cn/showproblem.php?pid=2842
- http://acm.hdu.edu.cn/showproblem.php?pid=1452 因子求和
- http://acm.hdu.edu.cn/showproblem.php?pid=1203(背包问题)
- http://acm.hdu.edu.cn/showproblem.php?pid=1142
- http://acm.hdu.edu.cn/showproblem.php?pid=4477
- HDU 1702 队列与栈的简单运用http://acm.hdu.edu.cn/showproblem.php?pid=1702
- http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理
- 找新朋友(http://acm.hdu.edu.cn/showproblem.php?pid=1286)
- http://acm.hdu.edu.cn/webcontest/contest_showproblem.php?cid=963&pid=1019&ojid=1
- http://acm.hdu.edu.cn/showproblem.php?pid=2602
- 找规律。。&&http://acm.hdu.edu.cn/showproblem.php?pid=1097
- Beans http://acm.hdu.edu.cn/showproblem.php?pid=2845
- http://acm.hdu.edu.cn/showproblem.php?pid=4544
- http://acm.hdu.edu.cn/showproblem.php?pid=1087
- 栈的简单应用 HDU 1022 http://acm.hdu.edu.cn/showproblem.php?pid=1022
- http://acm.hdu.edu.cn/showproblem.php?pid=1548
- http://acm.hdu.edu.cn/showproblem.php?pid=2110
- 并查集 小希的迷宫http://acm.hdu.edu.cn/showproblem.php?pid=1272
- 完数 &&http://acm.hdu.edu.cn/showproblem.php?pid=1406