#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++