Cod sursa(job #1909030)
| Utilizator | Data | 7 martie 2017 11:27:24 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 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 Pow_Lg(int x, int p)
{
int aux = 1;
while(p)
{
if(p & 1)
{
aux = (1LL*aux*x)%mod;
p--;
}
x = (1LL*x*x)%mod;
p/=2;
}
return aux;
}
int main()
{
fin >> N >> P;
fout << Pow_Lg(N,P) << "\n";
fout << "\n";
return 0;
}
