#include <bits/stdc++.h> #include <math.h> using namespace std; int main() { int n; while (cin >> n) { if (n == 0) { cout << 1 << endl; continue; } long long r = n; for (int i = 0; i < n-1; ++i) { r *= n; } cout << r%10 << endl; } return 0; } |
Double click to view unformatted code.