Cod sursa(job #1182088)
| Utilizator | Data | 4 mai 2014 18:30:31 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.32 kb |
#include <cstdio>
int main()
{
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
const long long int mod = 1999999973;
long long int n, p, e;
scanf("%lld %lld", &n, &p);
e = 1;
while (p != 0) {
if (p % 2 == 1)
e = (e * n) % mod;
n = (n * n) % mod;
p /= 2;
}
printf("%lld", e);
return 0;
}
