Cod sursa(job #2467787)
Utilizator | Data | 5 octombrie 2019 08:16:41 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.37 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)
{
if(n%2==1)
p=1LL*p*a%Mod;
n/=2;
a=1LL *a*a%Mod;
}
return p;
}
int main()
{
int n,p;
fin >> n >> p;
fout<<LogP(n,p);
return 0;
}