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