Cod sursa(job #1131811)
Utilizator | Data | 1 martie 2014 16:35:01 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include <cstdio>
const int mod = 1999999973;
int main() {
freopen("lgput.in", "rt", stdin);
freopen("lgput.out", "wt", stdout);
long long a, b;
scanf("%lld%lld", &a, &b);
long long c = 1;
while (b) {
if (b % 2) {
c *= a;
}
a *= a;
b /= 2;
a %= mod;
c %= mod;
}
printf("%lld", c);
}