题目链接:http://ac.jobdu.com/problem.php?pid=1441

 

详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus

 

参考代码:

//
//  1441 人见人爱 A ^ B.cpp
//  Jobdu
//
//  Created by PengFei_Zheng on 15/04/2017.
//  Copyright © 2017 PengFei_Zheng. All rights reserved.
//
 
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <cmath>
 
using namespace std;
 
int a,b;
 
 
int main(){
    while(scanf("%d%d",&a,&b)!=EOF){
        if(0==a && 0==b) break;
        int ans = 1;
        while(b!=0){
            if(b%2==1){
                ans *= a;
                ans%=1000;
            }
            b/=2;
            a*=a;
            a%=1000;
        }
        printf("%d\n",ans);
    }
    return 0;
}
/**************************************************************
    Problem: 1441
    User: zpfbuaa
    Language: C++
    Result: Accepted
    Time:0 ms
    Memory:1520 kb
****************************************************************/

 

相关文章:

  • 2022-12-23
  • 2021-10-10
  • 2021-06-22
  • 2021-11-14
  • 2021-10-05
  • 2021-05-30
  • 2021-06-01
猜你喜欢
  • 2022-12-23
  • 2022-01-11
  • 2021-10-13
  • 2021-05-05
  • 2021-12-27
  • 2022-01-10
  • 2022-12-23
相关资源
相似解决方案