Mai intai trebuie sa te autentifici.
Cod sursa(job #2178743)
Utilizator | Data | 19 martie 2018 18:15:34 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fcin("lgput.in");
ofstream fcout("lgput.out");
int power(int x, int y)
{
if (y == 0)
return 1;
int d = power(x, y / 2);
if (y % 2 == 0)
return d * d;
return x * d * d;
}
int main()
{
int N, P;
fcin >> N >> P;
fcout << power(N, P) % 1999999973;
}