Cod sursa(job #2690093)
Utilizator | Data | 22 decembrie 2020 23:09:32 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f ("lgput.in");
ofstream g ("lgput.out");
long long N,P;
long long exp(long long N,long long P)
{
long long x=1;
if (P==1)
return N;
if (P%2)
x*=N;
return x*exp(N,P/2)%1999999973*exp(N,P/2)%1999999973;
}
int main()
{
f>>N>>P;
cout<<exp(N,P);
}