View Code of Problem 3696

#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
//#define N 100
using namespace std;
int main()
{
	long long int N;
	while( scanf("%lld", &N )!=EOF)
	{
		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.


Back to problem 3696