Cod sursa(job #1726745)
| Utilizator | Data | 8 iulie 2016 20:52:08 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.44 kb |
#include <bits/stdc++.h>
long long power(int n, int e) {
if (e == 0) return 1;
if (e == 1) return n;
if (n % 2 == 0) return power(n * n, e / 2);
if (n % 2 != 0) return n * power(n * n, (e - 1) / 2);
}
int main() {
FILE *fin = fopen("lgput.in", "r");
FILE *fout = fopen("lgput.out", "w");
int n, e;
fscanf(fin, "%d %d", &n, &e);
long long x = power(n, e);
fprintf(fout, "%lld\n", x % 1999999973);
fclose(fin);
fclose(fout);
}
