Cod sursa(job #558224)

Utilizator CodrynhoLupascu Codrin Codrynho Data 17 martie 2011 09:57:11
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.3 kb
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long int n,px,rez,r,p;
int main()
{
fin>>p;
rez=1;
px=p;
fin>>n;
while(n>0)
{
r=n%2;
if(r==1)
{
rez=(rez%1999999973*px%1999999973)%1999999973;
}
n=n/2;
px=(px*px)%1999999973;
}
fout<<rez;
}