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