Pagini recente » Cod sursa (job #22209) | Cod sursa (job #2330439) | Cod sursa (job #470335) | Cod sursa (job #1345188) | Cod sursa (job #504278)
Cod sursa(job #504278)
#include <stdio.h>
#define NMax 100000
const char IN[]="farfurii.in",OUT[]="farfurii.out";
int N,K;
bool ap[NMax];
void Write(int N,int sum)
{
int i;
freopen(OUT,"w",stdout);
for (i=N;i>=1 && sum;i--)
if (i<=sum+1)
printf("%d ",i),
sum-= (i-1),
ap[i]=1;
for (i=1;i<=N;i++)
if (!ap[i])
printf("%d ",i);
fclose(stdout);
}
int main()
{
freopen(IN,"r",stdin);
scanf("%d%d",&N,&K);
fclose(stdin);
Write(N,K);
return 0;
}