Cod sursa(job #672389)
Utilizator | Data | 1 februarie 2012 23:10:22 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.28 kb |
#include <fstream>
#define M 1999999973;
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long n,p,produs=1;
int main()
{f>>n>>p;
n=n%M;
while (p)
{if (p%2==1) produs=(produs*n)%M;
n=(n*n)%M;
p/=2;
}
g<<produs<<'\n';
return 0;
}