Problem Statement
Two Sets II
Implementation
void solve()
{
ll n;
cin >> n;
ll s = n * (n + 1);
s /= 2;
if (s & 1)
{
cout << 0 << "\n";
return;
}
s /= 2;
vll dp(s + 1, 0LL);
dp[0] = 1;
FOR(i, 1, n)
{
vll temp = dp;
FOR(j, 0, s)
{
if (j - i >= 0)
{
if (j == 8)
{
cerr << j << " " << i << " " << temp[j - i] << "\n";
}
dp[j] += temp[j - i];
dp[j] %= mod;
}
}
}
debug(dp);
ll ans = powermod(2, mod - 2, mod);
ans *= dp[s];
ans %= mod;
cout << ans << "\n";
}