题目描述:
源码:
/**/ #include"iostream" using namespace std; int main() { int t, mod; long long n; cin>>t; for(int i = 0; i < t; i++) { cin>>n; mod = n % 10; if(mod == 0 || mod == 1 || mod == 5 || mod == 6) { cout<<mod<<endl; } else { switch(mod) { case 2: mod = n % 4; if(mod == 0) { cout<<6<<endl; } else if(mod == 1) { cout<<2<<endl; } else if(mod == 2) { cout<<4<<endl; } else { cout<<8<<endl; } break; case 3: mod = n % 4; if(mod == 0) { cout<<1<<endl; } else if(mod == 1) { cout<<3<<endl; } else if(mod == 2) { cout<<9<<endl; } else { cout<<7<<endl; } break; case 4: if(n % 2 == 1) { cout<<4<<endl; } else { cout<<6<<endl; } break; case 7: mod = n % 4; if(mod == 0) { cout<<1<<endl; } else if(mod == 1) { cout<<7<<endl; } else if(mod == 2) { cout<<9<<endl; } else { cout<<3<<endl; } break; case 8: mod = n % 4; if(mod == 0) { cout<<6<<endl; } else if(mod == 1) { cout<<8<<endl; } else if(mod == 2) { cout<<4<<endl; } else { cout<<2<<endl; } break; case 9: if(n % 2 == 1) { cout<<9<<endl; } else { cout<<1<<endl; } break; } } } return 0; }