Cod sursa(job #2211479)
| Utilizator | Data | 10 iunie 2018 15:36:07 | |
|---|---|---|---|
| Problema | Loto | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.65 kb |
#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;
}
