Cod sursa(job #2141349)
| Utilizator | Data | 24 februarie 2018 11:58:31 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.48 kb |
#include <iostream>
#include <fstream>
#define MOD 1999999973
using namespace std;
typedef unsigned long long int lint;
lint N, P;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
unsigned long long int DEIPower(lint x, lint P) {
if (P == 1) return x;
if (P % 2 == 0) {
return DEIPower(x * x, P / 2);
}
return x * DEIPower(x * x, P / 2);
}
int main()
{
fin >> N >> P;
N %= MOD;
fout << DEIPower(N, P);
return 0;
}
