Cod sursa(job #2753217)
Utilizator | Data | 21 mai 2021 16:36:20 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include <stdio.h>
#define MOD 1999999973;
long long x, n;
int main() {
/*
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
*/
scanf("%d %d", &x, &n);
int r = 1;
while (n >= 1) {
if (n % 2) {
r *= x;
}
x = x * x;
n /= 2;
r %= MOD;
x %= MOD;
}
printf("%d\n", r);
return 0;
}