Cod sursa(job #1464999)

Utilizator GeiGeiGeorge Cioroiu GeiGei Data 26 iulie 2015 11:43:15
Problema Loto Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.31 kb
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <climits>
#include <list>
#include <iomanip>
#include <cstdlib>
#include <fstream>
#include <map>
#include <algorithm>
#define nmax 10

using namespace std;

void afis (int** m, int n, int k) {
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= k; j++)
            cout << m[i][j] << " ";
        cout << "\n";
    }
    cout << "\n";
}

int main() {
    freopen("loto.in", "r", stdin);
    freopen("loto.out", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, s;
    cin >> n >> s;
    int* v = new int[n];
    for (int i = 0; i < n; i++)
        cin >> v[i];
    for (int x1 = 0; x1 < n; x1++)
        for (int x2 = x1; x2 < n; x2++)
            for (int x3 = x2; x3 < n; x3++)
                for (int x4 = x3; x4 < n; x4++)
                    for (int x5 = x4; x5 < n; x5++)
                        for (int x6 = x5; x6 < n; x6++)
                            if (v[x1] + v[x2] + v[x3] + v[x4] + v[x5] + v[x6] == s) {
                                cout << v[x1] << " " << v[x2] << " " << v[x3] << " " << v[x4] << " " << v[x5] << " " << v[x6];
                                return 0;
                            }
    cout << -1;

    return 0;
}