Cod sursa(job #2449657)
Utilizator | Data | 20 august 2019 13:35:30 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include <cstdio>
using namespace std;
typedef long long ll;
int main() {
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
int m = 1999999973, a, b, r = 1;
scanf("%d %d", &a, &b);
while (b) {
if (b & 1)
r = r * (ll) a % m;
a = a * (ll) a % m;
b /= 2;
}
printf("%d\n", r);
return 0;
}