1 /*
2 Author: Leo.W
3 Descriptipn: 計算N^N結果的最左邊的數
4 How to Do: 數學題 由sum=N^N,兩邊對10取對數,log10(sum)=Nlog10(N),有sum=10^(Nlog10(N));
5 由于10的整數次冪首位均為1,則僅需考慮Nlog10(N)的結果的小數部分即可
6 */
7 #include <stdio.h>
8 #include <math.h>
9 int main(){
10 //freopen("in.txt","r",stdin);
11 int t;
12 __int64 num,sum2;
13 scanf("%d",&t);
14 while(t--){
15 scanf("%I64d",&num);
16 double sum1=num*log10(double(num));
17 sum2=(__int64)sum1;
18 sum1-=sum2;
19 num=(__int64)pow(10.0,sum1);
20 printf("%I64d\n",num);
21 }
22 return 0;
23 }
posted on 2012-03-08 18:56
Leo.W 閱讀(877)
評論(1) 編輯 收藏 引用