Cod sursa(job #2635019)
| Utilizator | Data | 12 iulie 2020 23:14:00 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
#include <stdio.h>
#define MOD 1999999973
using namespace std;
FILE* fin, * fout;
int pow(int x, int e) {
if (e == 0)
return 1;
int t = pow(x, e / 2);
t = (t * t) % MOD;
if (e % 2 == 0) {
return t;
}
else {
return (t * x) % MOD;
}
}
int main()
{
fin = fopen("lgput.in", "r");
fout = fopen("lgput.out", "w");
int x, e;
fscanf(fin, "%i %i", &x, &e);
fprintf(fout,"%i", pow(x, e));
return 0;
}