c语言 人见人爱A^B

[复制链接]
查看11 | 回复1 | 2010-12-28 21:15:12 | 显示全部楼层 |阅读模式
人见人爱A^B
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 2 Accepted Submission(s) : 1
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
Problem Description
求A^B的最后三位数表示的整数。
说明:A^B的含义是“A的B次方”
Input
输入数据包含多个测试实例,每个实例占一行,由两个正整数A和B组成(1
int mul(int a,int b);
int main()
{int a,b,re;
while(scanf("%d%d",&a,&b)!=EOF&&!(a==0&&b==0));
{

printf("%d\n",mul(a%1000,b));
}
return 0;
}
int mul(int a,int b)
{ int re,mu;
if(b%2==0)
{mu=a*a%1000;
re=mul(mu,b/2);
return re%1000;
}
else if(b==1) return a;

else
{
mu=a*a%1000;
re=a*mul(mu,b/2);

return re%1000;
}
return re%1000;
}
怎么不对呀··

回复

使用道具 举报

千问 | 2010-12-28 21:15:12 | 显示全部楼层
while 后面多了;循环体没被执行
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行