当前位置:网站首页>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; }
边栏推荐
- TRACE32 - Common Operations
- 基于最小二乘法和SVM从天气预报中预测太阳能发电量(Matlab代码实现)
- Nuget package and upload tutorial
- Groupid(artifact id)
- Sentinel服务熔断和降级
- Message queue data storage MySQL table design
- Ubantu project 4: xshell, XFTP connected the virtual machine and set xshell copy and paste the shortcut
- Groupid(artifact id)
- [CUDA study notes] First acquaintance with CUDA
- Synchronized and volatile interview brief summary
猜你喜欢
Essential Learning for Getting Started with Unity Shader - Transparency Effect
[CUDA study notes] First acquaintance with CUDA
Five dimensions to start MySQL optimization
Sentinel服务熔断和降级
LeetCode二叉树系列——226.翻转二叉树
Unity Shader入门精要学习——透明效果
2021 OWASP TOP 10 漏洞指南
自适应控制——仿真实验三 用超稳定性理论设计模型参考自适应系统
华医网冲刺港股:5个月亏2976万 红杉与姚文彬是股东
深入浅出边缘云 | 4. 生命周期管理
随机推荐
LeetCode二叉树系列——226.翻转二叉树
修改SQL语言实现Mysql 多表关联查询优化
Getting started with UnityShader (3) - Unity's Shader
乡村基冲刺港交所:5个月期内亏2224万 SIG与红杉中国是股东
R language ggplot2 visualization: use the ggmapplot function of the ggpubr package to visualize the MA plot (MA-plot), the font.legend parameter and the font.main parameter to set the title and legend
The paper manual becomes 3D animation in seconds, the latest research of Wu Jiajun of Stanford University, selected for ECCV 2022
分成两栏后文字顺序混乱的问题解决【写期刊论文时】
Excel快速对齐表格的中姓名(两个字姓名和三个字姓名对齐)
Destruction order of thread_local variables
力扣:738.单调递增的数字
R语言ggstatsplot包ggbarstats函数可视化条形图、并添加假设检验结果(包含样本数、统计量、效应大小及其置信区间、显著性、组间两两比较、贝叶斯假设)、检验结果报告符合APA标准
DBeaver连接MySQL 8.x时Public Key Retrieval is not allowed 错误解决
学习笔记12--路径-速度分解法之局部路径搜索
STM32(十)------- SPI通信
微信聊天记录中搜索红包
《微信小程序-进阶篇》Lin-ui组件库源码分析-Icon组件
Kubernetes原理剖析与实战应用手册,太全了
R语言检验样本是否符合正态性(检验样本是否来自一个正态分布总体):shapiro.test函数检验样本是否符合正态分布(normality test)
NPM淘宝镜像(最新版本)于2021-11-21 16:53:52发布新版本npm镜像[通俗易懂]
大健云仓冲刺美股:增营收反减利润 京东与DCM是股东