#include<bits/stdc++.h> using namespace std; int main() { long long n; cin>>n; int a[10] = {0,1,4,9,6,5,6,9,4,1};// i^2 remainder int d,z; d = z = n; int ans,temp=1; while(z> 2) { d%= 10; if(z%2!=0) { temp = (temp*d)%10; } d = a[d]; z= z/2; } ans = (d*temp)%10; cout<<ans; }
若是哪里出错了还但愿你们指出,毕竟我也只是个菜鸟鸭,谢谢你们啦!c++