Cod sursa(job #186535)
Utilizator | Data | 28 aprilie 2008 10:29:52 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.31 kb |
#include<fstream.h>
#define sok 1999999973
using namespace std;
int main()
{
ifstream be ("lgput.in");
ofstream ki ("lgput.out");
long x,y,d=1;
be>>x>>y;
be.close();
for (;y>0;y/=2)
{
if (y%2)
d=(d*x)%sok;
x=(x*x)%sok;
}
ki<<d<<'\n';
ki.close();
return 0;
}