#include<iostream> using namespace std; int main() { int N, b; //0 1 5 6 多少次方都不变(0次方除外) //arr记录0-9 2次方开始的规律 int arr[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 }; while(scanf("%d",&N)!=EOF) { if(N==0 || N==1) b=1; else { b=arr[N%10][(N-2)%4]; } printf("%d\n",b); } } |
Double click to view unformatted code.