Cod sursa(job #1914372)
Utilizator | Data | 8 martie 2017 16:40:22 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.45 kb |
#include <bits/stdc++.h>
#define MOD 1999999973
using namespace std;
int N,P;
int LgPut(int a,int b)
{
int sol;
sol=1;
while(b>=1)
{
if(b%2==1)
sol=1LL*sol*a%MOD;
b/=2;
a=1LL*a*a%MOD;
}
return sol;
}
int main()
{
ifstream fin("lgput.in");
ofstream fout("lgput.out");
fin>>N>>P;
fout<<LgPut(N,P)<<"\n";
fin.close();
fout.close();
return 0;
}