Cod sursa(job #2492551)
Utilizator | Data | 14 noiembrie 2019 21:48:24 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.4 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/=2;
if(cf)
rez=rez*nlaputere%1999999973;
nlaputere=nlaputere*nlaputere%1999999973;
}
fout<<rez;
return 0;
}