Cod sursa(job #331152)

Utilizator Alexa_ioana_14Antoche Ioana Alexandra Alexa_ioana_14 Data 12 iulie 2009 21:28:48
Problema Loto Scor 15
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.91 kb
#include<cstdio>
#define N 101
int v[N],s;
short int n;
void citire()
{
	freopen("loto.in","r",stdin);
	freopen("loto.out","w",stdout);
	scanf("%hd%d",&n,&s);
	for (int i=1; i<=n; ++i)
		scanf("%d",&v[i]);
}
void tractor()
{
	for (int i1=1; i1<=n; ++i1)
		if (s-v[i1]>0)
		for (int i2=1; i2<=n; ++i2)
			if (s-v[i1]-v[i2]>0)
			for (int i3=1; i3<=n; ++i3)
				if (s-v[i1]-v[i2]-v[i3]>0)
				for (int i4=1; i4<=n; ++i4)
					if (s-v[i1]-v[i2]-v[i3]-v[i4]>0)
					for (int i5=1; i5<=n; ++i5)
						if (s-v[i1]-v[i2]-v[i3]-v[i4]-v[i5]>0)
						for (int i6=1;i6<=n;++i6)
						if (v[i1]+v[i2]+v[i3]+v[i4]+v[i5]+v[i6]==s)
						{
							printf("%d ",v[i1]);
							printf("%d ",v[i2]);
							printf("%d ",v[i3]);
							printf("%d ",v[i4]);
							printf("%d ",v[i5]);
							printf("%d ",v[i6]);
							return;
						}
					
	printf("-1");
}
int main()
{
	citire();
	tractor();
	return 0;
}