Cod sursa(job #246221)
Utilizator | Data | 20 ianuarie 2009 13:08:23 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.3 kb |
#include<fstream.h>
#define ok 1999999973
int main()
{
ifstream f ("lgput.in");
ofstream g ("lgput.out");
long long a,b,d=1;
f>>a>>b;
f.close();
while (b>0)
{
if (b%2)
d=(d*a)%ok;
a=(a*a)%ok;
b/=2;
}
g<<d<<'\n';
g.close();
return 0;
}