Cod sursa(job #2400955)
Utilizator | Data | 9 aprilie 2019 12:21:07 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include<bits/stdc++.h>
using namespace std;
long long prod(int a,int b){
int m=1;
while(b>1){
if(b%2==0) a*=a;
else {
m*=a;
a*=a;
}
a%=1999999973;
m%=1999999973;
b/=2;
}
return m*a;
}
int main(){
ifstream fin("logput.in");
ofstream fout("logput.out");
long long n,p;
fin>>n>>p;
fout<<prod(n,p);
return 0;
}