Cod sursa(job #413464)

Utilizator ClasianMunteanu Petre Clasian Data 8 martie 2010 17:13:08
Problema Loto Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.63 kb
#include<fstream.h>
ifstream x("loto.in");
ofstream g("loto.out");
int n,i,a,b,c,d,e,f,s,k,v[100];
int main()
{ x>>n>>k; 
  for(i=1;i<=n;i++)f>>v[i];
  for(a=1;a<=n;a++) { s+=v[a];
  for(b=1;b<=n;b++) { s+=v[b];
  for(c=1;c<=n;c++) { s+=v[c];
  for(d=1;d<=n;d++) { s+=v[d];
  for(e=1;e<=n;e++) { s+=v[e];
  for(f=1;f<=n;f++) { s+=v[f];
                      if(s==k) { g<<v[a]<<' '<<v[b]<<' '<<v[c]<<' '<<v[d]<<' '<<v[e]<<' '<<v[f];
								  return 0;
							   }
					  s-=v[f];}
					  s-=v[e];}
					  s-=v[d];}
					  s-=v[c];}
					  s-=v[b];}
					  s-=v[a];}
  g<<-1;
  x.close();
  g.close();
  return 0;
}