Cod sursa(job #3377338)
| Utilizator | Data | 22 noiembrie 2026 22:32:13 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.5 kb |
#include <iostream>
#include <fstream>
using namespace std;
const long long MOD = 1999999973;
int main()
{
FILE *fin, *fout;
fin = fopen("lgput.in", "r");
fout = fopen("lgput.out", "w");
long long x, p, rasp;
fscanf(fin, "%lld%lld", &x, &p);
rasp = 1;
while (p > 0){
if (p % 2 == 1){
rasp = rasp * x % MOD;
}
x = x * x % MOD;
p = p / 2;
}
fprintf(fout, "%lld", rasp);
fclose(fin);
fclose(fout);
}
