Cod sursa(job #2467799)
Utilizator | Data | 5 octombrie 2019 08:21:15 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <bits/stdc++.h>
#define MOD 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int LogP(int a, int n)
{
int p=1;
while (n>0)
{
if (n%2==1)
{
p=1ll*p*a%MOD;
}
a=1ll*a*a%MOD;
n/=2;
}
return p;
}
int main()
{
int a,b;
fin >> a >> b;
fout << LogP(a,b);
return 0;
}