Cod sursa(job #1647099)
Utilizator | Data | 10 martie 2016 19:00:39 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.3 kb |
#include <fstream>
using namespace std;
int a, p, x, k;
const int mod=1999999973;
ifstream f("lgput.in");
ofstream g("lgput.out");
int main()
{ f>>x>>k;
a=1;
for (p=1; p<=k; p=p*2)
{ if (k&p)
a=(a*x)%mod;
x=(x*x)%mod;
}
g<<a;
return 0;
}