Pagini recente » Cod sursa (job #2718105) | Cod sursa (job #824984) | Cod sursa (job #766096) | Cod sursa (job #643219) | Cod sursa (job #2519800)
#include <fstream>
using namespace std;
ifstream fin("loto.in");
ofstream fout("loto.out");
int v[128], n, s;
bool found;
void citire() {
fin >> n >> s;
for(int i = 1; i <= n; i++)
fin >> v[i];
}
void solve() {
for(int a = 1; a <= n; a++)
for(int b = 1; b <= n; b++)
for(int c = 1; c <= n; c++)
for(int d = 1; d <= n; d++)
for(int e = 1; e <= n; e++)
for(int f = 1; f <= n; f++)
if(v[a]+v[b]+v[c]+v[d]+v[e]+v[f] == s) {
fout << v[a] << ' ' << v[b] << ' ' << v[c] << ' ' << v[d] << ' ' << v[e] << ' ' << v[f];
found = true;
return;
}
}
int main() {
citire();
solve();
if(!found) fout << -1;
}