Cod sursa(job #2718723)
Utilizator | Data | 9 martie 2021 08:35:14 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <bits/stdc++.h>
#define MOD 1999999973
#define ULL unsigned long long int
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
ULL lggput(ULL n, ULL p)
{
ULL r=1;
while(p)
{
if(p%2==1) r=(r*n)%MOD;
n=(n*n)%MOD;
p/=2;
}
return r%MOD;
}
int main()
{
ULL n,p;
fin>>n>>p;
fout<<(lggput(n,p)%MOD);
}