【题目描述】
幂a^b的末3位数是多少?
【输入】
两个正整数a,b。1≤a≤100,1≤b≤10000。
【输出】
从高位到低位输出幂的末三位数字,中间无分隔符。若幂本身不足三位,在前面补零。
【输入样例】
7 2011
【输出样例】
743
【代码】
#include<iostream>
using namespace std
;
int main()
{
int a
, b
;
cin
>> a
>> b
;
int s
= 1 ;
while(b
--)
{
s
*= a
;
s
%= 1000 ;
}
if( s
>= 100 )
cout
<< s
<< endl
;
else if(s
>=10)
cout
<< "0" << s
<< endl
;
else
cout
<< "00" << s
<< endl
;
return 0 ;
}
转载请注明原文地址:https://blackberry.8miu.com/read-2265.html