Pagini recente » Cod sursa (job #1949060) | Cod sursa (job #1604751) | Cod sursa (job #1792348) | Cod sursa (job #1919045) | Cod sursa (job #943815)
Cod sursa(job #943815)
#include<fstream>
#include<vector>
using namespace std;
const int kmod = 666019;
class obj{
public:
int x, y, z, key;
obj(){};
obj(int x1, int y1, int z1){
x = x1;
y = y1;
z = z1;
key = (x + y + z) % kmod;
}
};
vector<obj> h[kmod];
int isthere(int key){
if(key < 0)
return 0;
if(!h[key].empty())
return 1;
return 0;
}
void add(obj A){
h[A.key].push_back(A);
}
int main(){
ifstream in("loto.in");
ofstream out("loto.out");
int n, s;
in >> n >> s;
int a[105];
for(int i = 1; i <= n; ++i)
in >> a[i];
for(int i = 1; i <= n; ++i)
for(int j = i; j <= n; ++j)
for(int k = j; k <= n; ++k){
obj t(a[i], a[j], a[k]);
if(isthere((s - t.key) % kmod)){
int key = (s - t.key) % kmod;
out << t.x << " " << t.y << " " << t.z << " " << h[key][0].x << " " << h[key][0].y << " " << h[key][0].z;
return 0;
}
else
add(t);
}
out << "-1";
return 0;
}