暴力解決不了問題,有規律可循, 只需看末尾數字即可, 末尾數字的 n 次方是有規律的 #includeusing namespace std; int main(){ int n; int t; while(scanf(%d,&t) != EOF){ while(t--){ scanf(%d, &n); if(n%10 == 0) printf(0 ); else if(n%10 == 1) printf(1 ); else if(n%10 == 2){ if(n%4 == 0) printf(6 ); else printf(4 ); } else if(n%10 == 3){ if((((n/10)%10)%2) == 0) printf(7 ); else printf(3 ); } else if(n%10 == 4) printf(6 ); else if(n%10 == 5) printf(5 ); else if(n%10 == 6) printf(6 ); else if(n%10 == 7) { if((((n/10)%10)%2) == 0) printf(3 ); else printf(7 ); } else if(n%10 == 8){ if((((n/10)%10)%2) == 0) printf(6 ); else printf(4 ); } else if(n%10 == 9) printf(9 ); } } return 0; }