https://vjudge.net/problem/15708/origin
题意就是输出所得数字的个位数,也就是对10取模,快速幂的模板题
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
ll fast_pow(ll x,ll y,int m){
if(y==0)return 1;
ll res=fast_pow(x*x%m,y/2,m);
if(y&1)res*=x%m;
return res;
}
int main(){
ll n,m;
cin>>n;
while(n--){
cin>>m;
ll e=fast_pow(m,m,10);
cout<<e%10<<endl;
}
return 0;
}