Cod sursa(job #2178753)
| Utilizator | Data | 19 martie 2018 18:20:07 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 30 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.5 kb |
#include <iostream>
#include <fstream>
using namespace std;
const long long MOD = 1999999973;
ifstream fcin("lgput.in");
ofstream fcout("lgput.out");
long long power(long long x, long long y)
{
if (y == 0)
return 1;
if (y == 1)
return x % MOD;
long long d = power(x, y / 2) % MOD;
if (y % 2 == 0)
return (d * d) % MOD;
return (x * d * d) % MOD;
}
int main()
{
long long N, P;
fcin >> N >> P;
fcout << power(N, P);
}
