Cod sursa(job #920106)
Utilizator | Data | 20 martie 2013 01:01:21 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include<fstream>
#define R 1999999973
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long N,P;
long long pow(long long b,long long e)
{
if (e==1) return b;
if (e%2==0) return pow(b*b,e/2)%R;
else return (pow(b*b,e/2)*b )%R;
}
int main()
{
f>>N>>P;
g<<pow(N,P)%R;
return 0;
}