View Code of Problem 3696

#include<stdio.h>
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
using namespace std;


int main()
{
	long long 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