Cod sursa(job #1380257)
| Utilizator | Data | 7 martie 2015 04:40:07 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int MOD = 1999999973;
int Power(int N, int P)
{
int Sol = 1;
while(P)
{
if(P & 1)
Sol = (1LL * Sol * N) % MOD;
N = (1LL * N * N) % MOD;
P >>= 1;
}
return Sol;
}
void Read()
{
int x, y;
fin >> x >> y;
fout << Power(x, y);
}
int main()
{
Read();
return 0;
}
