Cod sursa(job #2797425)

Utilizator robertanechita1Roberta Nechita robertanechita1 Data 9 noiembrie 2021 21:09:27
Problema Oite Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.81 kb
#include <bits/stdc++.h>

using namespace std;

ifstream fin("oite.in");
ofstream fout("oite.out");

int n, L, a[1100], s[500500], sp[500500], k, cnt, f[2030][2030];

int main()
{
    fin >> n >> L;
    for(int i = 1; i <= n; i++)
        fin >> a[i];
    for(int i = 1; i <= n; i++)
        for(int j = i+1; j <= n; j++)
            if(a[i] != a[j])
    {
        int x = a[i] + a[j];
        int y = a[i]*a[i] + a[j]*a[j];
        s[++k] = x;
        sp[k] = y;
    }
    for(int i = 1; i <= k; i++)
        for(int j = i + 1; j <= k; j++)
    {
        if(f[s[i]][s[j]] != 1 && s[j] != 0 && s[i] != s[j] && sp[i] != sp[j] && (s[i] + s[j] == L) )
        {
            f[s[i]][s[j]] = 1;
            f[s[j]][s[i]] = 1;
            cnt++;
        }
    }
    fout << cnt;
    return 0;
}