Pagini recente » Cod sursa (job #1880351) | Clasament simci2 | Cod sursa (job #2263060) | Infoarena Monthly 2014 - Solutii Runda 2 | Cod sursa (job #2391630)
#include <iostream>
#include <fstream>
using namespace std;
long long exp(long long a, long long b)
{
if (b == 0)
return 1;
if (b == 1)
return a;
if (b % 2 == 0)
{
return exp(a * a, b / 2);
}
else if (b % 2 != 0)
{
return a * exp(a * a, (b - 1) / 2);
}
}
int main()
{
fstream inFile;
inFile.open("lgput.in");
long long a, b;
inFile >> a >> b;
inFile.close();
ofstream outFile;
outFile.open("lgput.out");
outFile << exp(a, b);
outFile.close();
}