Pagini recente » Cod sursa (job #2901799) | Cod sursa (job #366295) | Cod sursa (job #2836836) | Cod sursa (job #2642919) | Cod sursa (job #1292105)
#include <fstream>
#include <vector>
using namespace std;
const int NMax = 110, MOD = 666013, SMax = 600000000;
struct str
{
int sum, x, y, z;
str ()
{
this -> sum = this -> x = this -> y = this -> z = 0;
}
str (const int sum, const int x, const int y, const int z)
{
this -> sum = sum;
this -> x = x;
this -> y = y;
this -> z = z;
}
};
int N, S;
int a[NMax];
vector <str> H[MOD];
int main()
{
ifstream f ("loto.in");
f >> N >> S;
for (int i = 1; i <= N; ++ i)
f >> a[i];
f.close();
for (int i = 1; i <= N; ++ i)
for (int j = i; j <= N; ++ j)
for (int k = j; k <= N; ++ k)
{
int nowsum = a[i] + a[j] + a[k];
int srch = S - nowsum;
if (srch < 0)
continue;
int code = srch % MOD;
for (vector <str> :: iterator it = H[code].begin(); it != H[code].end(); ++ it)
{
if (it -> sum == srch)
{
ofstream g ("loto.out");
g << i << " " << j << " " << k << " " << it -> x << " " << it -> y << " " << it -> z << "\n";
g.close();
return 0;
}
}
H[nowsum % MOD].push_back(str(nowsum, i, j, k));
}
ofstream g ("loto.out");
g << "-1\n";
g.close();
return 0;
}