Mai intai trebuie sa te autentifici.
Cod sursa(job #681908)
| Utilizator | Data | 18 februarie 2012 01:48:43 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.38 kb |
#include <fstream>
using namespace std;
#define MOD 1999999973;
int main()
{
long long sol = 1, x, n, f;
ifstream in("lgput.in"); in >> f >> n; in.close();
x = f;
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;
}
