Cod sursa(job #2221895)
Utilizator | Data | 16 iulie 2018 02:02:53 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long n,p,r,aux;
int main(){
fin>>n>>p;
if(p==0){
fout<<1;
return 0;
}
r=1; aux=n;
while(p>0){
if(p%2==1){
r=r*aux%1999999973;
}
aux=aux*aux;
aux%=1999999973;
p/=2;
}
fout<<r%1999999973;
return 0;
}