Cod sursa(job #2690087)
Utilizator | Data | 22 decembrie 2020 22:56:25 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.35 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)*exp(N,P/2);
}
int main()
{
f>>N>>P;
g<<exp(N,P)%1999999973;
}