n^n=10^( n*log10( n ) );
View Code
1 /* 2 n^n 的最高位 3 */ 4 #include<stdio.h> 5 #include<stdlib.h> 6 #include<string.h> 7 #include<iostream> 8 #include<algorithm> 9 #include<queue> 10 #include<map> 11 #include<math.h> 12 using namespace std; 13 const int maxn = 1005; 14 const int inf = 0x7fffffff; 15 int main(){ 16 int T; 17 scanf("%d",&T); 18 while( T-- ){ 19 int n; 20 scanf("%d",&n); 21 double tmp1,tmp2; 22 int tmp; 23 tmp1=n*1.0*log10(1.0*n); 24 tmp2=tmp1-(floor)(tmp1);//(int)强制转换 WA! 25 printf("%.0lf\n",(floor)(pow(10.0,tmp2))); 26 } 27 return 0; 28 }