Pagini recente » Cod sursa (job #1567132) | Cod sursa (job #261380) | Cod sursa (job #277572) | Cod sursa (job #722967) | Cod sursa (job #1180098)
#include <fstream>
#include <vector>
#define modulo 666013
using namespace std;
ifstream f("oite.in");
ofstream g("oite.out");
vector<int> hasht[modulo];
int c, l, i, o[1025], j, posib;
int hasht_find(int s)
{
int list = s%modulo;
int ap=0;
int sz=hasht[list].size();
for (int it=0; it<sz; it++)
if (hasht[list][it] == s)
ap++;
return ap;
}
int main()
{
f>>c>>l;
for (i=1; i<=c; i++)
f>>o[i];
for (i=1; i<=c; i++){
for (j=i+1; j<=c; j++)
if (l-o[i]-o[j]>0)
posib+=hasht_find(l-o[i]-o[j]);
for (j=1; j<=i-1; j++)
hasht[(o[i]+o[j])%modulo].push_back(o[i]+o[j]);
}
g<<posib;
return 0;
}