场上:快速幂括号里的两个变量忘了开ll了
改进:以后快速幂不要妄想用int
#include<cstdio> #include<iostream> #define ll long long using namespace std; const int MOD=1e9+7; ll poww(ll a,ll b){ ll ans=1; while(b){ if(b&1)ans=(ans*a)%10; a=(a*a)%10; b>>=1; } return ans;; } int main(){ int T; scanf("%d",&T); bool flag=false; while(T--){ ll n; cin>>n; ll ans=poww(n,n); cout<<ans<<endl; } return 0; }