Cod sursa(job #2838074)
Utilizator | Data | 23 ianuarie 2022 01:41:25 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int MOD=1999999973;
long long n,m,p;
int main()
{
fin >> m >> p;
n=1LL;
while(p)
{
if(p%2LL==1LL)
{
n=(n*m)%MOD;
p--;
}
else
{
n=(n*n)%MOD;
p/=2LL;
}
}
fout << n;
return 0;
}