Pagini recente » Cod sursa (job #3196999) | Cod sursa (job #3135338) | Cod sursa (job #990240) | Cod sursa (job #1131316) | Cod sursa (job #2211479)
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
int p[7],n,s, jel,x[100000000],a;
ifstream fin("loto.in");
ofstream fout("loto.out");
void bont(int i,int s)
{
int j,k;
for(j=1;j<=s;j++)
{
p[i]=j;
if(s-j>0)bont(i+1,s-j);
else if(i==6)
{ jel=1;
for(k=1;k<=i;k++)
if(x[p[k]]!=1)jel=0;
if(jel==1)
{for(k=1;k<=i;k++)
fout<<p[k]<<" "; exit(0);
}
}
}
}
int main()
{fin>>n>>s;
int i;
for(i=1;i<=n;i++)
{
fin>>a;
x[a]=1;
}
bont(1,s);
return 0;
}