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