HDU2035

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2035

又是一道快速幂。。。

#include<iostream>

int qp(int a,int b)
{
    int t=a%1000,s=1;
    while(b)
    {

        if(b & 1) 
            s=s*t%1000;
        t=t*t%1000;
        b>>=1;
    }
    return s;
}
int main()
{
    int a,b;
    while(scanf("%d%d",&a,&b),a,b)
    {
        printf("%d\n",qp(a,b));
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/hjq_xidian/article/details/52693541
今日推荐