Pagini recente » Cod sursa (job #1524661) | Cod sursa (job #1500629) | Cod sursa (job #2719849) | Cod sursa (job #3174775) | Cod sursa (job #1238628)
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
ifstream f("loto.in");
ofstream g("loto.out");
int a[100], n, S,t,i,ok=1,t1;
int compare(int a, int b)
{
return a < b;
}
int caut(int x)
{int p,u,t;
p=1;u=n;
while (p<=u)
{t=(p+u)/2;
if (a[t]==x) return 1;
else if (x<a[t]) u=t-1;
else p=t+1;
}
return 0;
}
int main()
{
f >> n >> S;
for ( i = 1; i <= n; i++)
{
f >> a[i];
}
sort(a+1, a+n+1, compare);
t=S/6;
while (!caut(t) && t>0) t--;
if (t==0) ok=0;
else
{t1=S-5*t;
if (!caut(t1)) ok=0;
}
if (!ok) g<<"-1";
else{
for (i=1;i<=5;i++) g<<t<<' ';
g<<t1;
}
f.close();g.close();
return 0;
}