Cod sursa(job #2442452)
Utilizator | Data | 24 iulie 2019 00:21:45 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
long long n,p,r;
fin>>n>>p;
r=1;
while(p){
if(p%2==0){
n=(n*n)%1999999973;
p=p/2;
}
else{
r=(r*n)%1999999973;
p--;
}
}
fout<<r%1999999973;
return 0;
}