#include<iostream> #include<cstring> //#include<algorithm> using namespace std; int a[10][4]={{0},{1},{6,2,4,8},{1,3,9,7},{6,4}, {5},{6},{1,7,9,3},{6,8,4,2},{1,9}}; int main(){ int n; while(~scanf("%lld",&n)){ if(n == 0)cout<<1<<endl; else{ int k = n % 10; if(k == 0 || k == 1 || k == 5 || k == 6)printf("%d",a[k][0]); if(k == 4 || k == 9)printf("%d",a[k][n%2]); if(k == 2 || k == 3 || k == 7 || k == 8)printf("%d",a[k][n%4]); printf("\n"); } } return 0; } |
Double click to view unformatted code.