Cod sursa(job #470522)

Utilizator Catah15Catalin Haidau Catah15 Data 14 iulie 2010 14:00:51
Problema Loto Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.67 kb
#include <iostream>
#include <fstream>
using namespace std;

ifstream f("loto.in");
ofstream g("loto.out");

long int n,s,x[101];
	
void citire()
{	
	int i;
	f>>n>>s;
	for(i=1; i<=n; i++)
		f>>x[i];
	f.close();
}

void search ()
{
	long int a,b,c,d,e,f;
	
	for(a=1; a<=n; a++)
		for(b=1; b<=n; b++)
			for(c=1; c<=n; c++)
				for(d=1; d<=n; d++)
					for(e=1; e<=n; e++)
						for(f=1; f<=n; f++)
							if(x[a]+x[b]+x[c]+x[d]+x[e]+x[f]==s)
							{
								g<<x[a]<<" "<<x[b]<<" "<<x[c]<<" "<<x[d]<<" "<<x[e]<<" "<<x[f];
								g.close();
								return;
							}
	g<<-1;
	g.close();
	
}

int main()
{
	citire();
	search();
	return 0;
}