Pagini recente » Cod sursa (job #2805296) | Cod sursa (job #687684) | Diferente pentru jc2016 intre reviziile 6 si 7 | Cod sursa (job #753480) | Cod sursa (job #2057783)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int exp_log (int n, int p)
{
if (p == 0)
return 1;
if (p == 1)
return n;
if (p%2 == 0)
return (exp_log(n*n, p/2));
if (p%2 == 1)
return (n*exp_log(n*n, (p-1)/2));
}
int main()
{
int N, P;
fin>>N>>P;
fout<<exp_log(N, P);
}