Cod sursa(job #937740)
Utilizator | Data | 10 aprilie 2013 22:48:48 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.33 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) % c;
temp = (temp * temp) % c;
y /= 2;
}
fout<<rez;
return 0;
}