description
Known maximum length of 200 positive integer n, a request 2011 ^ n after four.
Format
input format
of the first acts a positive integer k, k sets of data representatives (k≤200), the next k rows, each row has a positive integer n, n is the number of bits ≤200.
Output format of
a result of each n is an integer per line, if less than 4, the removal of excess high 0.
Sample
input Sample
3
5
28
792
Sample Output
1051
81
5521
Limit
time limit: 1000 ms
Memory Limit: 65536 KB
This is the big problem with fast integer + power too cumbersome, you can find out the rules by playing table, cycle 500
void change(char s[201],int a[201],int len){
for(int i=0;i<len;i++){
a[i]=s[len-i-1]-'0';
}
}
int main(){
int k,i;
char s[201];int a[201];
scanf("%d",&k);
while(k--){
scanf("%s",s);
int n=0,len=strlen(s);
memset(a,0,sizeof(a));
change(s,a,len);
n+=a[0];
n+=a[1]*10;
n+=a[2]*100;
n%=500;
int num=1;
for(i=0;i<n;i++){
num*=2011;
num%=10000;
}
printf("%d\n",num);
}
return 0;
}