Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 19050 Accepted Submission(s): 7329
1 #include<iostream> 2 using namespace std; 3 4 int table[10][10]={ 5 0,0,0,0,0,0,0,0,0,0, 6 1,1,1,1,1,1,1,1,1,1, 7 2,4,8,6,2,4,8,6,2,4, 8 3,9,7,1,3,9,7,1,3,9, 9 4,6,4,6,4,6,4,6,4,6, 10 5,5,5,5,5,5,5,5,5,5, 11 6,6,6,6,6,6,6,6,6,6, 12 7,9,3,1,7,9,3,1,7,9, 13 8,4,2,6,8,4,2,6,8,4, 14 9,1,9,1,9,1,9,1,9,1 15 }; 16 17 int cnt[10]={10,10,4,4,2,10,10,4,4,2}; 18 19 int main() 20 { 21 int t; 22 int n; 23 scanf("%d",&t); 24 while(t--) 25 { 26 scanf("%d",&n); 27 int temp=n; 28 temp%=10; 29 if(!temp) 30 { 31 printf("0\n"); 32 continue; 33 } 34 printf("%d\n",table[temp][(n-1)%cnt[temp]]); 35 } 36 return 0; 37 }