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