标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 16762 Accepted Submission(s): 6643
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
Sample Output
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 using namespace std; 6 7 int main() 8 { 9 int t; 10 int n; 11 scanf("%d",&t); 12 while(t--) 13 { 14 scanf("%d",&n); 15 double temp=n*log10(n*1.0); 16 double res=temp-floor(temp); 17 printf("%d\n",(int)pow(10.0,res)); 18 } 19 return 0; 20 }
标签:
原文地址:http://www.cnblogs.com/haoabcd2010/p/5964838.html