Cod sursa(job #2185929)
Utilizator | Data | 25 martie 2018 10:19:49 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <fstream>
using namespace std;
ifstream fin ("lgput.in");
ofstream fout ("lgput.out");
unsigned long long n,p,nlaput,m,rez;
int main()
{
fin>>n>>p;
nlaput=n;
rez=1;
m=1999999973;
while (p>0)
{
if (p%2==1)
rez=(rez*nlaput)%m;
p/=2;
nlaput=(nlaput*nlaput)%m;
}
fout<<rez;
return 0;
}