Cod sursa(job #2980274)

Utilizator Theo20067Cismaru Theodor-Alexe Theo20067 Data 16 februarie 2023 12:22:31
Problema Oite Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.7 kb
#include <fstream>
#define MOD 1011111
#include <vector>
using namespace std;
ifstream fin ("oite.in");
ofstream fout("oite.out");
int n,x,i,j,P,T,ok,V[1030],L,l,sol;
vector <int>H[MOD];
int main ()
{
    fin>>n>>L;
    for(i=1;i<=n;i++)
        fin>>V[i];
    for(i=1;i<n;i++)
    {
        for(j=i+1;j<=n;j++)
        {
            x=L-V[j]-V[i];
            if(x<0)
                continue;
            P=x%MOD;
            for(l=0;l<H[P].size();l++)
                if(H[P][l]==x)
                    sol++;
        }
        for(j=1;j<i;j++)
        {
            x=V[i]+V[j];
            P=x%MOD;
            H[P].push_back(x);
        }
    }
    fout<<sol;
    return 0;
}