Mai intai trebuie sa te autentifici.
Cod sursa(job #415340)
Utilizator | Data | 11 martie 2010 10:35:50 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <fstream>
#include <cstdlib>
using namespace std;
#define MOD 1999999973
long long n,p,rez,e;
int main()
{
ifstream f("lgput.in");
f>>n>>p;
f.close();
e = n;
rez = 1;
for (int i = 1; i <= p; i<<=1)
{
if (p&i) rez = (rez * e) % MOD;
e = (e * e) % MOD;
}
ofstream g("lgput.out");
g<<rez;
g.close();
return EXIT_SUCCESS;
}