Pagini recente » Cod sursa (job #284214) | Statistici Viorica (viorica1) | Cod sursa (job #961284) | Istoria paginii runda/training_day_5/clasament | Cod sursa (job #1522569)
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
#define ULL unsigned long long
ULL n, k;
ULL rd(ULL x, ULL n);
int main()
{
fin >> n >> k;
fout << rd(n,k);
fin.close();
fout.close();
return 0;
}
ULL rd(ULL x, ULL n)
{
if ( !n )
return 1;
if ( n == 1 )
return x;
if ( x % 2 == 0 )
return rd(x * x, n / 2);
if ( x % 2 == 1 )
return x * rd( x * x, (n - 1) / 2);
}