Mai intai trebuie sa te autentifici.
Cod sursa(job #953457)
| Utilizator | Data | 26 mai 2013 11:22:49 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.39 kb |
#include<iostream>
#include<fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long N,P;
const int m=1999999973;
long long lg(long long N,long long P)
{if (P==0 ) return 1;
else if (P==1) return N;
else if (P%2==0) return lg(N*N, P/2);
else return N*lg(N*N, (P-1)/2);
}
int main()
{f>>N>>P;
g<<lg(N,P)%m;
return 0;
}
