题目:http://acm.hdu.edu.cn/showproblem.php?pid=1061
代码:
#include<stdio.h>
#include<string.h>
using namespace std;
int fast(long long x)
{
long long temp=x;
long long ans=1;
long long base=1;
while(x)
{
if(x%2==1)
ans=(ans*temp)%10;
temp=(temp*temp)%10;
x=x/2;
}
return ans;
}
int main()
{
long long a;
int t;
scanf("%d",&t);
while(t--)
{
scanf("%lld",&a);
printf("%d\n",fast(a));
}
}