Cod sursa(job #1513923)
Utilizator | Data | 30 octombrie 2015 11:29:13 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <cstdio>
const int nmax = 10001;
const int mod = 1999999973;
int main()
{
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
long long sol=1, n, p;
scanf("%lld %lld", &n, &p);
while(p)
{
if(p&1) sol=(sol*n)%mod;
p=p>>1;
n=(n*n)%mod;
}
printf("%lld\n", sol);
return 0;
}