Pagini recente » Cod sursa (job #2474014) | Cod sursa (job #1458407) | Cod sursa (job #2186797) | Cod sursa (job #1271510) | Cod sursa (job #2917587)
#include <iostream>
#include <fstream>
std::ifstream fin("lgput.in");
std::ofstream fout("lgput.out");
int logarithmic(int n, int p)
{
if (p == 0)
{
return 1;
}
if (p % 2 == 1)
{
return n * logarithmic(n, p - 1);
}
if (p % 2 == 0)
{
n = logarithmic(n, p/2);
return n * n;
}
}
int main() {
int n, p;
fin >> n >> p;
fout << logarithmic(n, p);
return 0;
}