Cod sursa(job #558226)
Utilizator | Data | 17 martie 2011 09:58:08 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.32 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long int n,pn,rez,r,p;
int main()
{
fin>>p;
rez=1;
pn=p;
fin>>n;
while(n>0)
{
r=n%2;
if(r==1)
{
rez=(rez%1999999973*px%1999999973)%1999999973;
}
n=n/2;
pn=(pn*pn)%1999999973;
}
fout<<rez;
}