Cod sursa(job #2178761)
| Utilizator | Data | 19 martie 2018 18:24:18 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.48 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;
long long d = power(x, y / 2);
if (y % 2 == 0)
return (d * d);
return (x * d * d);
}
int main()
{
long long N, P;
fcin >> N >> P;
fcout << power(N, P) % MOD;
}
