我承认这题是用来找自信的。。。快速幂
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;
int qpow(int n)
{
int ans=1,b=n%10;
while (n)
{
if (n%2==1)
{
n--;ans*=b;
ans%=10;
}
else
{
n/=2;
b*=b;
b%=10;
}
}
return ans%10;
}
int main()
{
int t,n;
cin>>t;
while (t--)
{
cin>>n;
cout<<qpow(n)<<endl;
}
return 0;
}