Cod sursa(job #308243)
| Utilizator | Data | 26 aprilie 2009 16:13:19 | |
|---|---|---|---|
| Problema | Combinari | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.44 kb |
#include<stdio.h>
int m,n,s[19];
void solutie()
{
int i;
for(i=1;i<=m;i++)
printf("%d ",s[i]);
printf("\n");
}
void back()
{
int k=1,up;
s[k]=0;
while(k)
{
up=0;
while(!up&&s[k]<n-m+k)
{
s[k]++;
up=1;
}
if(up)
if(k==m)solutie();
else k++,s[k]=s[k-1];
else
k--;
}
}
int main()
{
freopen("combinari.in","r",stdin);
freopen("combinari.out","w",stdout);
scanf("%d%d",&n,&m);
back();
return 0;
}