首页 > 汉堡猪猪分糖果
头像 DPsans
发表于 2026-02-16 15:20:30
·题意给定n颗糖果,要求分成m份,每份c_i (c_i >= 1)个, 求c_1 & c_2 & c_3 & ... & c_m 的最大值。·分析·首先我们知道,根据位与&的特性,就算有某些c_i 占据了高的数位,有一个c_j 在该位上为0,那& 展开全文
头像 FoolBlade
发表于 2026-03-20 13:11:38
#include <bits/stdc++.h> using namespace std; #define int long long #define dbg(x) cout<<#x<<": "<<(x)<<endl; 展开全文
头像 腌萝卜干
发表于 2026-03-20 13:34:14
按位贪心 核心点是如果当前为是, 并且, 如果 但是, , 是剩余所有位填的结果, 必须将这些糖果消耗掉!, 也就是个糖果需要消耗掉, 注意上取整 #include <bits/stdc++.h> #define x first #define y second #define all 展开全文