Pagini recente » Cod sursa (job #337754) | Cod sursa (job #2009601) | Cod sursa (job #199300) | Cod sursa (job #712405) | Cod sursa (job #3130678)
#include <iostream>
#include <fstream>
#include <unordered_map>
using namespace std;
ifstream fin("loto.in");
ofstream fout("loto.out");
struct trio{
int primu;
int doilea;
int treilea;
};
int main(){
unordered_map<int,trio> tabel;
int n,sum,check = 0;
fin>>n>>sum;
int numere[n];
for(int i = 0 ; i < n ; i++)
fin>>numere[i];
for(int i = 0 ; i < n; i++){
for(int j = 0 ; j < n ; j++){
for(int k = 0 ; k < n ; k++){
int suma = numere[i] + numere[j] + numere[k];
tabel[suma] = {numere[i],numere[j],numere[k]};
if(tabel.find(sum - suma) != tabel.end()){
if(!check)
fout<<tabel[sum-suma].primu<<" "<<tabel[sum-suma].doilea<<" "<<tabel[sum-suma].treilea<<" "<<numere[i]<<" "<<numere[j]<<" "<<numere[k];
check = 1;
}
}
// if(check)
// break;
}
// if(check)
// break;
}
if(!check)
fout<<-1;
fin.close();
fout.close();
return 0;
}