Pagini recente » Cod sursa (job #842222) | Cod sursa (job #2413583) | Cod sursa (job #2481833) | Cod sursa (job #3280214) | Cod sursa (job #2897298)
#include<fstream>
using namespace std;
ifstream fin("planeta.in");
ofstream fout("planeta.out");
long long n, v[31], k;
void sol(long long st, long long dr, long long k){
long long i=st;
while(v[i-st]*v[dr-i]<=k && i<=dr){
k-=v[i-st]*v[dr-i];
i++;
}
fout<<i<<" ";
if(st<i)
sol(st, i-1, k/v[dr-i]);
if(dr>i)
sol(i+1, dr, k%v[dr-i]);
}
int main(){
fin>>n>>k;
v[0]=1;
for(int i=1; i<=n; i++){
for(int j=1; j<=i; j++)
v[i]+=v[i-j]*v[j-1];
}
k--;
sol(1, n, k);
}