当前位置:网站首页>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; }
边栏推荐
- Advanced Mathematics - Commonly Used Indefinite Integral Formulas
- 模板与泛型编程值typelist实现
- LeetCode二叉树系列——110.平衡二叉树
- RecyclerView高效使用第三节
- Message queue data storage MySQL table design
- R language test whether the sample conforms to normality (test whether the sample comes from a normally distributed population): shapiro.test function tests whether the sample conforms to the normal d
- 为什么毕业季不要表白?
- The role of /etc/profile, /etc/bashrc, ~/.bash_profile, ~/.bashrc files
- Sentinel热点参数限流
- 自适应控制——仿真实验三 用超稳定性理论设计模型参考自适应系统
猜你喜欢
随机推荐
Word table to Excel
Word表格转到Excel中
Small test knife: Go reflection helped me convert Excel to Struct
浏览器自带的拾色器
Ubuntu Topic 5: Setting a Static IP Address
基于最小二乘法和SVM从天气预报中预测太阳能发电量(Matlab代码实现)
charles进行弱网测试(app弱网测试怎么做)
架构实战营模块8消息队列表结构设计
thread_local 变量的析构顺序
DBeaver连接MySQL 8.x时Public Key Retrieval is not allowed 错误解决
The role of /etc/profile, /etc/bashrc, ~/.bash_profile, ~/.bashrc files
Web自动化实战——Selenium4(自动化测试环境的搭建)
Introduction to BigDecimal, common methods
UnityShader入门学习(三)——Unity的Shader
公告
The paper manual becomes 3D animation in seconds, the latest research of Wu Jiajun of Stanford University, selected for ECCV 2022
高等数学——常用不定积分公式
svn安装及使用(身体功能手册)
Unity Shader入门精要学习——透明效果
leetcode303场周赛复盘