Cod sursa(job #3243509)
Utilizator | Data | 19 septembrie 2024 09:22:15 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <iostream>
#include <fstream>
using namespace std;
long long power(long long x, long long n) {
if (n == 0) return 1;
if (n % 2) return x * power(x * x, n/2);
return power(x * x, n / 2);
}
int main() {
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long n, p;
fin >> n >> p;
fout << power(n, p) % 1999999973;
return 0;
}