#include <stdio.h> #include <math.h> using namespace std; int main(){ int N; long long int a; while( ~scanf("%d", &N )){ if( N==0 ) printf("1\n"); else if( N%4 == 1 ){ printf("%d\n", N%10 ); }else if( N%4 == 2 ){ N = N%10; printf("%d\n", N*N%10); }else if( N%4 == 3 ){ N = N%10; printf("%d\n", N*N*N%10); }else{ printf("%d\n", N*N*N*N%10); } } return 0; } |
Double click to view unformatted code.