当前位置:网站首页>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; }
边栏推荐
- 乡村基冲刺港交所:5个月期内亏2224万 SIG与红杉中国是股东
- 435. 无重叠区间
- Ubuntu Topic 5: Setting a Static IP Address
- 《微信小程序-进阶篇》Lin-ui组件库源码分析-Icon组件
- Architecture actual combat battalion module 8 message queue table structure design
- R language moves time series data forward or backward (custom lag or lead period): use the lag function in the dplyr package to move the time series data forward by one day (set the parameter n to a p
- 实现防抖与节流函数
- ASP.NET Core 产生连续 Guid
- 为什么黑客领域几乎一片男生?
- 分成两栏后文字顺序混乱的问题解决【写期刊论文时】
猜你喜欢

Excel quickly aligns the middle name of the table (two-word name and three-word name alignment)

乡村基冲刺港交所:5个月期内亏2224万 SIG与红杉中国是股东

OpenCV测量物体的尺寸技能 get~

思路迪医药冲刺港股:5个月亏2.9亿 泰格医药与先声药业是股东

Getting started with UnityShader (1) - GPU and Shader

四象限时间管理有多好用?

TRACE32——C源码关联

RecyclerView的高效使用第一节

TRACE32 - SNOOPer-based variable logging

abaqus find contact pairs报错:surface name is already in use
随机推荐
分成两栏后文字顺序混乱的问题解决【写期刊论文时】
2021 OWASP TOP 10 漏洞指南
自动化测试如何创造业务价值?
力扣:738.单调递增的数字
高等数学——常用不定积分公式
How useful is four-quadrant time management?
UnityShader入门学习(二)——渲染流水线
PDF 拆分/合并
Architecture actual combat battalion module 8 message queue table structure design
架构实战营模块8消息队列表结构设计
三角恒等变换公式
深入浅出边缘云 | 4. 生命周期管理
UnityShader入门学习(三)——Unity的Shader
Female service community product design
Efficient use of RecyclerView Section 1
实现防抖与节流函数
AVH Deployment Practice (1) | Deploying the Flying Paddle Model on Arm Virtual Hardware
自适应控制——仿真实验三 用超稳定性理论设计模型参考自适应系统
Synchronized and volatile interview brief summary
C language basic practice (nine-nine multiplication table) and printing different asterisk patterns