Cod sursa(job #1934059)
Utilizator | Data | 21 martie 2017 09:10:03 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.47 kb |
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
int main()
{
unsigned long long n,p,produs=1,paux,naux,ctr;
f>>n>>p;
while(p!=0)
{
paux=p;
naux=n;
ctr=1;
while(paux!=1)
{
naux*=naux;
paux=paux>>1;
ctr=ctr<<1;
}
p=p-ctr;
produs*=naux;
}
g<<produs%1999999973;
f.close();
g.close();
}