时间限制: 1000 ms 内存限制: 65536 KB
提交数: 8039 通过数: 4718
【题目描述】
幂ab的末3位数是多少?
【输入】
两个正整数a,b。1≤a≤100,1≤b≤10000。
【输出】
从高位到低位输出幂的末三位数字,中间无分隔符。若幂本身不足三位,在前面补零。
【输入样例】
7 2011
【输出样例】
743
【来源】
NO
代码
#include <stdio.h>
int main ()
{
int a,b,c=1;
scanf("%d %d",&a,&b);
for(int i=1;i<=b;i++)
{
c*=a;
if(c>1000)
{
c%=1000;
}
}
if(c<100) printf("%03d",c);
else printf("%3d",c);
return 0;
}