Cod sursa(job #2608241)
Utilizator | Data | 30 aprilie 2020 20:56:01 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include <cstdio>
#define MOD 1999999973
int main() {
int b, e, r = 1;
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
scanf("%d%d", &b, &e);
while(e) {
if(e % 2)
r = (r * b) % MOD;
b = (b * b) % MOD;
e /= 2;
}
printf("%d ", r);
}