Pagini recente » Cod sursa (job #310218) | Cod sursa (job #76679) | Cod sursa (job #1511543) | Profil TeamFIIG | Cod sursa (job #1017943)
#include <fstream>
#include <cstdlib>
using namespace std;
ifstream is("loto.in");
ofstream os("loto.out");
int n, s, v[101];
int x[7], suma;
void SOLVE(int q);
void WRITE();
int main()
{
is >> n >> s;
for ( int i = 1; i <= n; ++i )
is >> v[i];
SOLVE(1);
os << "-1";
is.close();
os.close();
return 0;
}
void SOLVE(int q)
{
if ( q == 7 )
if ( suma == s )
WRITE();
else
return;
for ( int i = 1; i <= n; ++i )
{
x[q] = v[i];
suma += x[q];
SOLVE(q + 1);
suma -= x[q];
}
}
void WRITE()
{
for ( int i = 1; i <= 6; ++i )
os << x[i] << " ";
exit(0);
}