Cod sursa(job #1672829)
Utilizator | Data | 3 aprilie 2016 10:05:59 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.45 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long n ,p, i, j, aux, r=1, r1;
int main()
{
fin>>n>>p;
while(p>0)
{
aux=p%2;
if(aux)
{
r=r*n;
r=r%1999999973;
p--;
}
else
{
p=p/2;
n=n*n;
n=n%1999999973;
}
}
fout<<r;
return 0;
}