Cod sursa(job #292431)

Utilizator RoswenRus Alexandru Roswen Data 31 martie 2009 09:53:13
Problema Loto Scor 5
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.65 kb
#include<stdio.h>
long long v[101], s;
int a,b,c,d,e,f,i,n,x;
int  calc(int &a, int &b, int &c, int &d, int &e, int &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(v[a]+v[b]+v[c]+v[d]+v[e]+v[f]==s) return 1;

return 0;
}
int main()
{
 freopen("loto.in","r",stdin);
 freopen("loto.out","w",stdout);
 scanf("%d%lld", &n, &s);
 for(i=1;i<=n;i++)
	scanf("%d", &v[i]);
 if(v[n]*6<s) printf("-1");
	else
	{
	x=calc(a,b,c,d,e,f);
	if (x==1)

 printf("%lld %lld %lld %lld %lld %lld", v[a], v[b],v[c], v[d], v[e], v[f]);
  }
 return 0;
}