Cod sursa(job #279551)
Utilizator | Data | 12 martie 2009 21:11:20 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.27 kb |
#include <fstream.h>
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long x,n,rez=1;
long modulo=1999999973;
int main()
{fin>>x>>n;
while (n)
{if (n%2) rez=(rez*x)%modulo;
x=(x*x)%modulo;
n/=2;
}
fout<<rez;
fout.close();
return 0;
}