A的B次方取余

#include <cstdio>
using namespace std;
int main()
{
    const int c = 1000;
    int a, b;
    int i;
    int outcom;

    /*乘积的取余等于取余的乘积*/
    while(true){
        scanf("%d%d", &a, &b );
        if( !a && !b )      /*a b 都为零则停止循环*/
            break;
        outcom = 1;
        for( i=0; i<b; i++ ){
            outcom = outcom *a % c;
        }
        printf("%d\n", outcom );
    }

    return 0;
}

猜你喜欢

转载自blog.csdn.net/hpu2022/article/details/79945543