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