Cod sursa(job #2578887)
| Utilizator | Data | 11 martie 2020 18:07:42 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | c-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.35 kb |
#include <stdio.h>
const int m = 1999999973;
int main ()
{
freopen("lgput.in", "r", stdin);
freopen ("lgput.out", "w", stdout);
long long a, b, r=1;
scanf("%lld", &a); scanf("%lld", &b);
for (; b; b>>=1)
{
if(b&1)
r=(r*a)%m;
a=(a*a)%m;
}
printf("%lld", r);
return 0;
}
