Cod sursa(job #937736)
Utilizator | Data | 10 aprilie 2013 22:44:40 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.29 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main ()
{
unsigned long x,y,c=1999999973,i,temp=1,rez=1;
fin>>x>>y;
temp=x;
while(y!=0)
{
if(y%2!=0)
rez=rez*temp;
temp=temp*temp;
y /= 2;
}
fout<<rez%c;
return 0;
}