Pagini recente » Cod sursa (job #2179537) | Cod sursa (job #2340927) | Cod sursa (job #1197395) | Cod sursa (job #1153028) | Cod sursa (job #3209772)
#include <fstream>
#include <algorithm>
#include <vector>
using namespace std;
ifstream cin("loto.in");
ofstream cout("loto.out");
int v[605], sum;
vector <int> ans;
void bkt(int n, int s, int nre, int pz) {
if (nre == 6) {
if (s == sum) {
for (auto x : ans)
cout << x << ' ';
exit(0);
}
return;
}
if (pz == n * 6 + 1)
return;
ans.push_back(v[pz]);
bkt(n, s + v[pz], nre + 1, pz + 1);
ans.pop_back();
bkt(n, s, nre, pz + 1);
}
int main() {
int n;
cin >> n >> sum;
for (int i = 1; i <= n; i++) {
cin >> v[(i - 1) * 6 + 1];
for (int j = (i - 1) * 6 + 2; j <= i * 6; j++)
v[j] = v[(i - 1) * 6 + 1];
}
bkt(n, 0, 0, 1);
cout << -1;
}