Cod sursa(job #2412271)
| Utilizator | Data | 21 aprilie 2019 21:41:23 | |
|---|---|---|---|
| Problema | Combinari | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.76 kb |
#include <cstdio>
using namespace std;
int n,k,sol[100];
bool verif(int x)
{
for(int i=2; i<=x; i++)
if(sol[i]<=sol[i-1])
return false;
return true;
}
void BK(int x)
{
if(x<=k)
{
for(int i=x; i<=n-k+x; i++)
{
sol[x]=i;
if(verif(x))
{
if(x==k)
{
for(int j=1; j<=k; j++)
printf("%d ",sol[j]);
printf("\n");
}
else
BK(x+1);
}
}
}
}
int main()
{
freopen("combinari.in","r",stdin);
freopen("combinari.out","w",stdout);
scanf("%d%d",&n,&k);
BK(1);
return 0;
}
