Pagini recente » Cod sursa (job #209844) | Cod sursa (job #668568) | Cod sursa (job #87839) | Cod sursa (job #1075818) | Cod sursa (job #331045)
Cod sursa(job #331045)
#include<stdio.h>
#define tip unsigned long long
tip L,a,n,k,N[110][110],A[110][110],AT[110],NT[110],LC,x,CC;
void read(),solve();
int main()
{
read();
solve();
return 0;
}
void read()
{
freopen("pavare2.in","r",stdin);
freopen("pavare2.out","w",stdout);
scanf("%llu%llu%llu",&L,&a,&n);
scanf("%llu",&k);
}
void solve()
{
for(LC=1;LC<=L;LC++)
{
for(x=1;x<=a;x++)
{
if(x>LC)A[LC][x]=0;
else
if(x==LC)A[LC][x]=1;
else
if(x==1)A[LC][x]=NT[LC-1];
else
A[LC][x]=A[LC-1][x-1];
AT[LC]+=A[LC][x];
}
for(x=1;x<=n;x++)
{
if(x>LC)N[LC][x]=0;
else
if(x==LC)N[LC][x]=1;
else
if(x==1)N[LC][x]=AT[LC-1];
else
N[LC][x]=N[LC-1][x-1];
NT[LC]+=N[LC][x];
}
}
printf("%llu\n",NT[L]+AT[L]);
LC=L;
if(AT[L]<k){k-=AT[L];CC=1;}
for(;;)
{
if(!LC)return;
if(CC==0)
{
for(x=a;;x--)
{
if(x>LC)continue;
if(A[LC][x]<k)k-=A[LC][x];
else break;
}
LC-=x;CC=1;
for(;x;x--)printf("0");
}
else
{
for(x=1;;x++)
{
if(N[LC][x]<k)k-=N[LC][x];
else break;
}
LC-=x;CC=0;
for(;x;x--)printf("1");
}
if(!LC)break;
}
}