acgo题库
  • 首页
  • 题库
  • 学习
  • 天梯
  • 备赛

    竞赛

    • CSP-J/S
    • 蓝桥杯

    考级

    • GESP
    • CPA
    • 电子学会考级
  • 竞赛
  • 讨论
  • 团队
登录
注册
题目详情提交记录(0)
  • 题解!!!!!

    #include <bits/stdc++.h> using namespace std; #define endl '\n' #define ll long long const int N = 1000 + 10; const int maxn = 2e5 + 10; const int inf = 0x3f3f3f3f; int a[maxn], b[maxn]; ll c0[3][30], c1[3][30]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); freopen("math.in", "r", stdin); freopen("math.out", "w", stdout); int n, x; cin >> n >> x; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) cin >> b[i]; for (int i = 1; i <= n; i++) { for (int j = 25; j >= 0; j--) { if ((a[i] >> j) & 1) c1[b[i]][j]; else c0[b[i]][j]; } } ll ans = 0; for (int i = 0; i <= x; i++) { ll res = 0; for (int j = 25; j >= 0; j--) { if ((i >> j) & 1) { res += c1[0][j] * (1 << j) + (c1[1][j] + c0[1][j]) * (1 << j) + c0[2][j] * (1 << j); } else { res += c1[1][j] * (1 << j) + c1[2][j] * (1 << j); } } ans = max(ans, res); } cout << ans << endl; cout.flush(); fclose(stdin); fclose(stdout); return 0; }

    userId_undefined

    俞锦博博博博

    贪心·贪心尝试者空间掌握者I/O·IO入门者
    29阅读
    0回复
    0点赞
暂无数据

提交答案之后,这里将显示提交结果~

首页