Cod sursa(job #1956109)
Utilizator | Data | 6 aprilie 2017 15:02:04 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include <iostream>
#include <fstream>
using namespace std;
long long n,p,x,mod=1999999973;
int main()
{freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
scanf("%lld%lld", &n, &p);
x=1;
while(p)
{if(p%2)
x=x*n%mod;
n=n*n%mod;
p=p/2;
}
printf("%lld", x);
return 0;
}