Cod sursa(job #2180819)
Utilizator | Data | 21 martie 2018 11:08:25 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.48 kb |
#include <fstream>
using namespace std;
long long n,p;
ifstream f("lgput.in");
ofstream g("lgput.out");
int lgpt(long long a,long long b)
{
long long x;
if(b==0)return 1;
else
{
if(b%2==0)
{
x=lgpt(a,b/2)%1999999973;
return x*x;
}
else
{
return a*lgpt(a,b-1)%1999999973;
}
}
}
int main()
{
f>>n>>p;
g<<lgpt(n,p)%1999999973<<'\n';
return 0;
}