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