Cod sursa(job #2470890)

Utilizator andreisontea01Andrei Sontea andreisontea01 Data 9 octombrie 2019 20:49:48
Problema Energii Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.48 kb
#include <bits/stdc++.h>

using namespace std;

const int MAXS = 800;

long long dp[MAXS];

int main()
{
    ifstream fin("semisume.in");
    ofstream fout("semisume.out");
    int n;
    fin >> n;
    int sum = n * (n + 1) / 2;
    if(sum % 2 == 1){
        fout << 0;
        return 0;
    }
    dp[0] = 1;
    for(int i = 1; i <= n; ++i){
        for(int j = sum / 2; j >= i; --j)
            dp[j] += dp[j - i];
    }
    fout << dp[sum / 2] / 2;
    return 0;
}