题目1441:人见人爱 A ^ B(二分求幂)

时间:2023-03-08 23:00:32
题目1441:人见人爱 A ^ B(二分求幂)

题目链接: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(==a && ==b) break;
int ans = ;
while(b!=){
if(b%==){
ans *= a;
ans%=;
}
b/=;
a*=a;
a%=;
}
printf("%d\n",ans);
}
return ;
}
/**************************************************************
Problem: 1441
User: zpfbuaa
Language: C++
Result: Accepted
Time:0 ms
Memory:1520 kb
****************************************************************/