Cod sursa(job #2354722)
Utilizator | Data | 25 februarie 2019 15:25:30 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long n,rez,nlaputere,p,modulo=1999999973;
int main()
{
fin>>n>>p;
nlaputere=n;
rez=1;
while(p)
{
if (p%2==1) rez=(rez*nlaputere)%modulo;
p/=2;
nlaputere=(nlaputere*nlaputere)%modulo;
}
fout<<rez<<'\n';
return 0;
}