Cod sursa(job #300737)

Utilizator andreivFMI - vacaroiu andrei andreiv Data 7 aprilie 2009 17:24:59
Problema Loto Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.54 kb
#include <stdio.h>
int main()
{long int x,y,z,n,s,v[100];
 char ok,sum[600000009],v1[600000009],v2[600000009],v3[600000009];

 freopen("loto.in","r",stdin);
 freopen("loto.out","w",stdout);
 scanf("%ld %ld",&n,&s);sum[0]=1;
 if (n<6) ok=1; else
 {ok=1;sum[0]=0;
  for (x=1;x<=n-2;x++)
    for (y=x+1;x<=n-1;y++)
	 for (z=y+1;x<=n;z++)
        if (v[x]+v[y]+v[z]<s)
		 {sum[v[x]+v[y]+v[z]]=1;
          if (sum[s-(v[x]+v[y]+v[z])])
		   {ok=0;printf("%ld %ld %ld ",v[x],v[y],v[z]);}
		 } 
 }
	
 if (ok) printf("-1");		   
 
 return 0;}