View Code of Problem 3696

#include<iostream>

using namespace std;

int main() {
	long long n;
	while (cin >> n) {
		if (n == 0) cout << 1 << endl;
		else if (n % 4 == 1) cout << n % 10 << endl;
		else if (n % 4 == 2) {
			n = n % 10;
			cout << n * n % 10 << endl;
		}
		else if (n % 4 == 3) {
			n = n % 10;
			cout << n * n * n % 10<<endl;
		}
		else {
			n = n % 10;
			cout << n * n * n * n % 10 << endl;
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 3696