Pagini recente » Borderou de evaluare (job #897795) | Cod sursa (job #1969579) | Cod sursa (job #2189510) | Cod sursa (job #1352702) | Cod sursa (job #365248)
Cod sursa(job #365248)
#include<stdio.h>
int n;
long long x,d[32];
void back(int l, int r, long long k)
{
int i=l;
for(;d[i-l]*d[r-i]<=k && i<=r;i++)
k-=d[i-l]*d[r-i];
printf("%d ",i);
if(l<i)
back(l,i-1,k/d[r-i]);
if(i<r)
back(i+1,r,k%d[r-i]);
}
int main()
{
freopen("planeta.in","r",stdin);
freopen("planeta.out","w",stdout);
scanf("%d%lld",&n,&x);
int i,j;
d[0]=1;
for(i=1;i<=n;i++)
for(j=1;j<=i;j++)
d[i]=d[i]+d[i-j]*d[j-1];
back(1,n,--x);
return 0;
}