标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 39554 Accepted Submission(s):
14930
#include<stdio.h>
#include<string.h>
int f(int x)
{
int ans=1;
int y=x;
x=x%10;
while(y)
{
if(y&1)
ans=(ans*x)%10;
y/=2;
x=(x*x)%10;
}
return ans;
}
int main()
{
int n,m,j,i,t;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
printf("%d\n",f(n));
}
return 0;
}
hdoj 1061 Rightmost Digit【快速幂求模】
标签:
原文地址:http://www.cnblogs.com/tonghao/p/4701470.html