Cod sursa(job #112180)

Utilizator xtephanFodor Stefan xtephan Data 3 decembrie 2007 17:21:38
Problema Loto Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.64 kb
#include<stdio.h>

long a[100], s;
int n;


void cit();
int rez();


int main() {

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

	cit();
	if(!rez())
		printf("-1");

	return 0;
}


void cit() {

	scanf("%d", &n);
	scanf("%ld", &s);

	for(int i=1; i<=n; i++)
		scanf("%ld", &a[i]);
}

int rez() {
	int q,w,e,r,t,y;

	for(q=1; q<=n; q++)
	for(w=1; w<=n; w++)
	for(e=1; e<=n; e++)
	for(r=1; r<=n; r++)
	for(t=1; t<=n; t++)
	for(y=1; y<=n; y++)
		if(a[q]+a[w]+a[e]+a[r]+a[t]+a[y] == s) {
			printf("%ld %ld %ld %ld %ld %ld", a[q],a[w],a[e],a[r],a[t],a[y]);
			return 1;

		}

	return 0;
}