Cod sursa(job #2145088)

Utilizator AlexAxeToporan Victor AlexAxe Data 27 februarie 2018 08:38:36
Problema Oite Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.69 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("oite.in");
ofstream out("oite.out");

const int NMax = 1026;
int N, M, L[NMax];

void Read(){
    in >> N >> M;
    for (int i = 1; i <= N; ++i)
        in >> L[i];
}

void Solve(){
    int Contor = 0;
    for (int i = 1; i <= N - 3; ++i)
        for (int j = i + 1; j <= N - 2; ++j)
            for (int k = j + 1; k <= N - 1; ++k)
                for (int l = k + 1; l <= N; ++l){
                    int S = L[i] + L[j] + L[k] + L[l];
                    if (S == M)
                        Contor ++;
                }
    out << Contor;
}

int main(){
    Read();
    Solve();
    return 0;
}