Cod sursa(job #650915)
Utilizator | Data | 19 decembrie 2011 10:58:02 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <fstream>
#define LL long long
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int MO = 1999999973;
int power(int a, int e) {
int x = a, y = 1;
for (; e; e >>= 1, x = (LL)x * x % MO) if (e & 1) y = (LL)y * x % MO;
return y;
}
int main()
{
int N , P;
fin>>N>>P;
fout<<power(N,P);
return 0;
}