Pagini recente » Cod sursa (job #3161231) | Cod sursa (job #2967633) | Cod sursa (job #3292798) | Cod sursa (job #2437097) | Cod sursa (job #1934693)
#include<fstream>
#include<set>
using namespace std;
ifstream fin("loto.in");
ofstream fout("loto.out");
set<int>s;
set<int>::iterator it;
int n,a,A[101];
inline void c(int aux){
for(int i=0;i<n;i++)for(int j=i;j<n;j++)for(int l=j;l<n;l++)if(A[i]+A[j]+A[l]==aux)fout<<A[i]<<' '<<A[j]<<' '<<A[l]<<' ';
}
int main(){
fin>>n>>a;
for(int i=0;i<n;i++)fin>>A[i];
for(int i=0;i<n;i++)for(int j=i;j<n;j++)for(int l=j;l<n;l++)s.insert(A[i]+A[j]+A[l]);
for(it=s.begin();it!=s.end();it++){
if(s.find((a-*it))!=s.end()){c(a-*it);c(*it);return(0);}
}fout<<"-1";
}