hdu 2035 人见人爱a^b

http://acm.hdu.edu.cn/showproblem.php?pid=2035

这道题目考察的是余数,因为((a%c)*(b%c))%b=(a*b)%c;所以这道题目就很简单了哦,相信你做了之后也会这样认为的。。。

代码::

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

int main()

{

    int n,m,k;

    while(scanf("%d%d",&n,&m),n&&m)

    {

            k=1;

            while(m--)

            {

                    k=k*(n%1000);

                    k=k%1000;

            } 

            printf("%d\n",k);

    } 

   // system("pause");

    return 0;

}

posted @ 2011-08-02 22:30  ○o尐懶錨o  阅读(360)  评论(0编辑  收藏  举报