Cod sursa(job #558217)
Utilizator | Data | 17 martie 2011 09:55:25 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.31 kb |
#include <fstream>
using namespace std;
ifstream fin ("lgput.in");
ofstream fout("lgput.out");
int x, n, r, px;
int main()
{
int modulo = 1999999973, rez=1;
fin>>x>>n;
px=x;
while (n)
{
r=n%2;
if(r)
rez=(rez*px)%modulo;
px=(px*px)%modulo;
n/=2;
}
fout << rez;
fout.close();
return 0;
}