Cod sursa(job #1390422)

Utilizator handsonthewheelSandel Georgel handsonthewheel Data 17 martie 2015 01:01:12
Problema Loto Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.91 kb
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#define N 400000
#define ll unsigned long long
#include <cstring>
using namespace std;
int a[1001];
int main(){
    freopen ("loto.in", "r", stdin);
    freopen ("loto.out", "w", stdout);
    ll s, pow;
    int n, i;
 scanf ("%d %llu", &n, &s);
 for (i=1;i<=n;i++) scanf ("%d", &a[i]);
 int i1, j, j1, k,k1;
  for (i=1;i<=n;i++){
    for (i1=1;i1<=n;i1++){
        if (a[i]+a[i1]>s) continue;
    for (j=1;j<=n;j++){
    if (a[i]+a[i1]+a[j]>s) continue;
    for (j1=1;j1<=n;j1++){
            if (a[i]+a[i1]+a[j]+a[j1]>s) continue;
    for (k=1;k<=n;k++){
        if (a[i]+a[k]+a[i1]+a[j]+a[j1]>s) continue;
    for (k1=1;k1<=n;k1++){
 if (a[i]+a[i1]+a[j]+a[j1]+a[k]+a[k1]==s){
        printf ("%d %d %d %d %d %d", a[i],a[i1],a[j],a[j1],a[k],a[k1]);
 return 0;
 }
  }
    }
    }
    }
    }
  }
printf ("%d", -1);
}