知识点:
求后几位就对10的几次方取余
注意下面的输入格式应为:“13**13”,因为scanf(“%d** %d”,&x,&y);
//求13的13次方的最后三位数
#include <stdio.h>
int main()
{
int i,x,y,last=1;//变量last保存求x的y次方过程中的部分乘积的后三位
printf("Input X and Y(X**Y):");
scanf("%d**%d",&x,&y);
for(i=1;i<=y;i++)//x自乘y次
last=last*x%1000;//将last乘x后对1000取模,即求积的后三位
printf("The last 3 digits of %d**%d is:%d\n",x,y,last%1000);//打印结果
return 0;
}