Cod sursa(job #591966)

Utilizator rudarelLup Ionut rudarel Data 26 mai 2011 09:12:11
Problema Loto Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.67 kb
#include <fstream.h>
#define MAX 101

int n;
unsigned long s, i, j, k, l, x, y, a[MAX];

int main()
{
	ifstream fin("loto.in");

	fin >> n >> s;

	for ( i = 1; i <= n; i++)
		fin >> a[i];

	fin.close();

	ofstream fout("loto.out");
	int ok = 1;

	for ( i = 1; i <= n; i++ )
	for ( j = 1; j <= n; j++ )
	for ( k = 1; k <= n; k++ )
	for ( l = 1; l <= n; l++ )
	for ( x = 1; x <= n; x++ )
	for ( y = 1; y <= n; y++ )
	if ( a[i] + a[j] + a[k] + a[l] + a[x] + a[y] == s )
	{
		ok = 0;
		fout << a[i] << " " << a[j] << " " << a[k] << " " << a[l] << " " << a[x] << " " << a[y];
		goto end;
	}

	if ( ok ) fout << -1;

end:	fout.close();

	return 0;
}