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