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