【问题标题】:Apple Division CSES Qustion SOlution苹果事业部 CSES Qustion 解决方案
【发布时间】:2020-10-22 08:33:12
【问题描述】:

所以这是问题https://cses.fi/problemset/task/1623 的链接。 这个代码sn-p是什么意思? :-

for (int i = 0; i < 1 << n; ++i)
{
    ll cs = 0;
    for (int j = 0; j < n; ++j)
        if (i >> j & 1)
            cs += p[j];
    if (cs <= s / 2)
        ans = max(ans, cs);
}

提前致谢。

【问题讨论】:

  • 你指的是哪一行代码?复制你想知道的代码sn-p,这样更容易回答。
  • 好吧,我做到了

标签: c++ operators bit explain


【解决方案1】:

它遍历数组的所有可能组合,并找到与总和的一半相等的最接近的总和。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-24
    • 2011-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多