Pagini recente » Cod sursa (job #3205633) | Cod sursa (job #905020) | Cod sursa (job #2726092) | Cod sursa (job #2427064) | Cod sursa (job #2899755)
#include <iostream>
#include <fstream>
using namespace std;
long long int u[35];
void bkt(int l, int r, long long int k)
{
int i = l;
while (i <= r && u[i-l] * u[r-i] <= k) {
k -= u[i-l] * u[r - i];
++i;
}
o<<i<<" ";
if (l < i)
bkt(l, i - 1, k / u[r - i]);
if (r > i)
bkt(i + 1, r, k % u[r - i]);
}
int main()
{
ifstream f("planeta.in");
ofstream o("planeta.out");
int n;
long long int k;
f>>n>>k;
u[0] = 1;
for (int i = 1; i <= n; ++i)
u[i] = 2 * (2 * i - 1) * u[i - 1] / (i + 1);
bkt(1, n, --k);
return 0;
}