1 Star 4 Fork 0

Sshwy/code

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
gym102956d.cpp 672 Bytes
一键复制 编辑 原始数据 按行查看 历史
Sshwy 提交于 4年前 . code format
// by Yao
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define ROF(i, a, b) for (int i = (a); i >= (b); --i)
namespace RA {
int rnd(int p) { return 1ll * rand() * rand() % p; }
int rnd(int L, int R) { return rnd(R - L + 1) + L; }
} // namespace RA
const int N = 1e6 + 5;
int n, b[100];
long long a[N], f[N];
int main() {
scanf("%d", &n);
FOR(i, 1, n) scanf("%lld", &a[i]);
FOR(i, 1, n) {
FOR(j, 0, 40) {
if (b[j]) f[i] = max(f[i], f[b[j]] + (a[b[j]] & a[i]));
if (a[i] >> j & 1) b[j] = i;
}
}
printf("%lld\n", *max_element(f + 1, f + n + 1));
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sshwy/code.git
git@gitee.com:sshwy/code.git
sshwy
code
code
master

搜索帮助