Cod sursa(job #3298632)
| Utilizator | Data | 31 mai 2025 19:18:42 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.48 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int MOD = 1999999973;
long long pow(long long x, long long exp) {
if (exp == 0) return 1;
x %= MOD;
long long a = 1;
if (exp % 2) a = x;
long long aux = pow(x, exp / 2);
aux = (aux * aux) % MOD;
return (aux * a) % MOD;
}
int main() {
long long n, p;
fin >> n >> p;
fout << pow(n, p);
return 0;
}
