Cod sursa(job #3356460)
| Utilizator | Data | 1 iunie 2026 15:34:00 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | c-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.59 kb |
#include <stdio.h>
typedef unsigned long long ull;
#define MOD 1999999973ULL
ull lgput(ull base, ull exp, ull mod) {
ull result = 1;
base %= mod;
while (exp > 0) {
if (exp & 1)
result = result * base % mod;
base = base * base % mod;
exp >>= 1;
}
return result;
}
int main() {
FILE *fin = fopen("lgput.in", "r");
FILE *fout = fopen("lgput.out", "w");
ull n, p;
fscanf(fin, "%llu %llu", &n, &p);
fprintf(fout, "%llu\n", lgput(n, p, MOD));
fclose(fin);
fclose(fout);
return 0;
}