Cod sursa(job #2172759)
Utilizator | Data | 15 martie 2018 17:47:16 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int mod = 1999999973;
int N,P;
inline int LgPow(int x, int p)
{
int aux = 1;
while(p)
{
if(p & 1) aux = (1LL * aux * x) %mod;
x = (1LL * x * x) %mod;
p /= 2;
}
return aux;
}
int main()
{
fin >> N >> P;
fout << LgPow(N,P) << "\n";
return 0;
}