Problem Statement
Money Sums
Implementation
void solve()
{
ll n;
cin >> n;
vll a(n);
rep(i, n) cin >> a[i];
sort(all(a));
ll mx = 1e5 + 1;
vll dp(mx + 1, 0);
dp[0] = 1;
rep(j, n)
{
vll temp = dp;
FOR(i, 1, mx)
{
if (i - a[j] >= 0)
{
dp[i] = (dp[i] | temp[i - a[j]]);
}
}
}
debug(dp);
vll ans;
rep(i, sz(dp))
{
if (i && dp[i])
ans.pb(i);
}
cout << sz(ans) << "\n";
for (auto &x : ans)
cout << x << " ";
cout << "\n";
}