Cod sursa(job #2376411)
Utilizator | Data | 8 martie 2019 15:29:03 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include <fstream>
#define MOD 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int n,p,sol;
int main ()
{
fin>>n>>p;
sol=1;
while(p!=1){
if(p%2==0){
n=(n*n)%MOD;
}
else{
sol=(sol*n)%MOD;
n=n*n;
}
p/=2;
}
sol=(sol*n)%MOD;
fout<<sol;
return 0;
}