当前位置:网站首页>Codeforces Round #796 (Div. 2)(A-D)
Codeforces Round #796 (Div. 2)(A-D)
2022-07-31 15:05:00 【eyuhaobanga】
tnnd,为什么不AKdiv2?(还不是因为不会做+时间少,知识点还好多没学QAQ
AC代码:
#include <bits/stdc++.h> #define rep(i,a,n) for(int i=a;i<n;i++) using namespace std; using LL = long long; void Solve() { int x; cin >> x; for (int i = 1; i <= 30; i++) { if (x == (1 << i)) { cout << x + 1 << "\n"; return; } } int y = x & (-x); while ((y ^ x) == 0 || (y & x) == 0) { y++; } cout << y << '\n'; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; rep (i, 0, T) { Solve(); } return 0; }AC代码:
#include <bits/stdc++.h> #define rep(i,a,n) for(int i=a;i<n;i++) using namespace std; using LL = long long; void Solve() { int n; cin >> n; int cnt = 0; vector<int> a(n); int ans = 0x3f3f3f3f; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] % 2 == 1) { cnt++; } } if (cnt) { ans = min(ans, n - cnt); } int sum = 0x3f3f3f3f; for (int i = 0; i < n; i++) { int x = 0; if (a[i] % 2 == 0) { while (a[i] % 2 != 1) { x++; a[i] >>= 1; } } sum = min(sum, x); } cout << min(ans, sum + n - 1) << '\n'; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; rep (i, 0, T) { Solve(); } return 0; }AC代码:
#include <bits/stdc++.h> #define rep(i,a,n) for(int i=a;i<n;i++) using namespace std; using LL = long long; void Solve() { int n; cin >> n; n <<= 1; vector<string> a(n); map<char, int> mp; for (int i = 0; i < n; i++) { cin >> a[i]; int len = a[i].size(); for (int j = 0; j < len; j++) { mp[a[i][j]]++; } } string s; cin >> s; int len = s.size(); for (int i = 0; i < len; i++) { mp[s[i]]++; } for (auto it : mp) { if (it.second % 2 == 1) { cout << it.first << '\n'; return; } } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; rep (i, 0, T) { Solve(); } return 0; }AC代码:
#include <bits/stdc++.h> #define rep(i,a,n) for(int i=a;i<n;i++) using namespace std; using LL = long long; void Solve() { int n, k; cin >> n >> k; vector<int> a(n); vector<LL> sum(n); rep (i, 0, n) { cin >> a[i]; if (i == 0) { sum[i] = a[i]; } else { sum[i] = a[i] + sum[i - 1]; } } int x = k / n; int y = k - x * n; LL ans = 0; if (x == 0) { for (int i = k - 1; i < n; i++) { if (i >= k) { ans = max(ans, sum[i] - sum[i - k]); } else { ans = max(ans, sum[i]); } } cout << ans + 1LL * k * (k - 1) / 2 << '\n'; return; } for (int i = 0; i < n; i++) { ans += 1LL * a[i] + i; } x--; ans += 1LL * n * x * n; ans += 1LL * y * n; cout << ans << '\n'; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; rep (i, 0, T) { Solve(); } return 0; }
边栏推荐
- 【MySQL】Mysql范式及外键作用
- R language ggplot2 visualization: use the ggboxplot function of the ggpubr package to visualize the box plot, use the font function to customize the font size, color, style (bold, italic) of the legen
- 实现防抖与节流函数
- LeetCode二叉树系列——226.翻转二叉树
- 使用 Chainlink Keepers 实现智能合约函数的自动化执行
- UnityShader入门学习(二)——渲染流水线
- Sentinel服务熔断和降级
- 看交互设计如何集成到Scrum敏捷流程中
- 力扣:56. 合并区间
- 自动化测试如何创造业务价值?
猜你喜欢
随机推荐
Word表格转到Excel中
Groupid(artifact id)
OpenCV测量物体的尺寸技能 get~
最小费用最大流问题详解
易驱线主控芯片对比(电动三轮电机90O瓦世纪通达)
Groupid(artifact id)
Efficient use of RecyclerView Section 3
R language ggplot2 visualization: use the ggboxplot function of the ggpubr package to visualize the box plot, use the font function to customize the font size, color, style (bold, italic) of the legen
《微信小程序-进阶篇》Lin-ui组件库源码分析-Icon组件
MANIFEST.MF文件(PDB文件)
Synchronized和volatile 面试简单汇总
自动化测试如何创造业务价值?
Getting started with UnityShader (1) - GPU and Shader
PDF 拆分/合并
力扣:738.单调递增的数字
大健云仓冲刺美股:增营收反减利润 京东与DCM是股东
RecyclerView的高效使用第一节
Architecture actual combat battalion module 8 message queue table structure design
NC | 斯坦福申小涛等开发数据可重复分析计算框架TidyMass
Spark学习(2)-Spark环境搭建-Local









