Pagini recente » Clasament .com 2009 | Cod sursa (job #1580531) | Cod sursa (job #207729) | Cod sursa (job #641384) | Cod sursa (job #1216440)
#include <cstdio>
#include <vector>
using namespace std;
#define MOD 666013
#define MP make_pair
#define PB push_back
#define NMAX 1005
vector < pair < long long , short > > H[MOD];
vector < pair < long long , short > > :: iterator e;;
int i,j,N,L,ans,f;
int V[NMAX];
long long X;
int main()
{
freopen("oite.in","r",stdin);
freopen("oite.out","w",stdout);
scanf("%d%d",&N,&L);
for (i=1;i<=N;++i)
scanf("%d",&V[i]);
for (i=1;i<=N;++i)
for (j=i+1;j<=N;++j)
H[(V[i]+V[j])%MOD].PB(MP(V[i]+V[j],j));
for (i=1;i<=N;++i)
for (j=i+1;j<=N;++j)
{
if (V[i]+V[j]>L) continue;
f=(L-V[i]-V[j])%MOD;
for (e=H[f].begin();e!=H[f].end();++e)
if (i>(*e).second)
++ans;
}
printf("%d\n",ans);
return 0;
}