Cod sursa(job #681905)
Utilizator | Data | 18 februarie 2012 01:36:06 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <fstream>
using namespace std;
#define MOD 1999999973;
int main()
{
unsigned int x, n;
long long sol = 1;
ifstream in("lgput.in"); in >> x >> n; in.close();
for(unsigned int i = 0; (1<<i)<=n; ++i)
{
if(((1<<i)&n) > 0)
sol = (sol*x)%MOD;
x = (x*x)%MOD;
}
ofstream out("lgput.out"); out << sol; out.close();
return 0;
}