Cod sursa(job #1487848)
| Utilizator | Data | 17 septembrie 2015 15:43:06 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 30 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.41 kb |
#include <iostream>
#include <fstream>
using namespace std;
long long N,P;
long long putere( long long x, int p)
{
int m=1999999973;
if (p==0)
return 1;
long long aux=putere (x,p/2);
if (p%2==0)
return aux*aux%m;
return aux*aux*x%m;
}
int main()
{
ifstream f("lgput.in");
ofstream g("lgput.out");
f>>N>>P;
g<<putere(N,P);
return 0;
}
