题目
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 
 2 
 3 
 4
Sample Output
2 
 2
Hint
In 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.
分析:
对一个数num可写为 num=a*10^n , 即科学计数法,使a的整数部分即为num的最高位数字 
 k^k=a*10^n 
 如何求a的值? 
 a=k^k/10^n 
 如何求n的值? 
 把n提出来,lga=k*lgk-n 
 n是整数,而且0 < k* lgk-n< 1, 这说明n是k * lgk的整数部分,因此n=(int)k*lgk 
 因此a=10^(k*lgk-(int)k *lgk) 
 实际上,由于k*lgk小数点后有许多数,而int 只有32 位,那么取整用(long long)
代码
#include<stdio.h>
#include<math.h>
int main(){int n;double x,a;scanf("%d",&n);while(n--){scanf("%lf",&a);x=a*log10(a);printf("%d\n",(int)pow(10.0,x-(long long)x));}
}