SMU Summer 2023 Contest Round 12
SMU Summer 2023 Contest Round 12
A. K-divisible Sum
分类讨论:
- \(n > k\)时:
- \(n\)能整除\(k\)就全是\(1\)
- 不能整除,最多就是在全\(1\)的基础上再一部分\(1\)
- \(n \leq k\)时:
- \(k\)能整除\(n\)就全放\(\frac{k}{n}\)
- 不能的话就在原基础上再加一部分\(1\)
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while (T--) {
int n, k;
cin >> n >> k;
if (n > k) {
if (n % k == 0)
cout << 1 << '\n';
else
cout << 2 << '\n';
} else {
if (k % n == 0)
cout << k / n << '\n';
else
cout << k / n + 1 << '\n';
}
}
return 0;
}
B. Inflation
按顺序去模拟即可,记得要向上取整
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while (T--) {
int n, k;
cin >> n >> k;
vector<int> p(n);
int sum = 0;
for (auto &i : p) {
cin >> i;
}
int ans = 0;
for (int i = 1; i < n ; i ++) {
sum += p[i - 1];
if (p[i] * 100 <= k * sum) continue;
ans += (ceil(p[i] * 100.0 / k) - sum);
sum += (ceil(p[i] * 100.0 / k) - sum);
}
cout << ans << '\n';
}
return 0;
}
C. Longest Simple Cycle
设\(dp[i]\)表示前\(i\)条链能组成环的最大点数
当\(a[i] = b[i]\)时,第\(i\)个点就是单独一个点闭环,\(dp[i] = c[i] + 1\),否则,就应该判断是否用\(a[i]\)和\(b[i]\)之间的点组成环,还是用两点之外的之前的链来组成环,当然还要包含后面的\(c[i]+1\)才能组成环
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<double, double> PII;
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while (T--) {
int n;
cin >> n;
vector<int> c(n), a(n), b(n);
for (auto &i : c) cin >> i;
for (auto &i : a) cin >> i;
for (auto &i : b) cin >> i;
vector<int> dp(n);
int ans = 0;
for (int i = 1; i < n; i ++) {
if (a[i] == b[i]) dp[i] = c[i] + 1;
else dp[i] = max(abs(a[i] - b[i]), dp[i - 1] - abs(a[i] - b[i])) + c[i] + 1;
ans = max(ans, dp[i]);
}
cout << ans << '\n';
}
return 0;
}
SMU Summer 2023 Contest Round 12的更多相关文章
- “玲珑杯”ACM比赛 Round #12题解&源码
我能说我比较傻么!就只能做一道签到题,没办法,我就先写下A题的题解&源码吧,日后补上剩余题的题解&源码吧! A ...
- Codeforces Beta Round #12 (Div 2 Only)
Codeforces Beta Round #12 (Div 2 Only) http://codeforces.com/contest/12 A 水题 #include<bits/stdc++ ...
- BestCoder Round #12 War(计算几何)
War Time Limit: 8000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submis ...
- Educational Codeforces Round 12 F. Four Divisors 求小于x的素数个数(待解决)
F. Four Divisors 题目连接: http://www.codeforces.com/contest/665/problem/F Description If an integer a i ...
- Codeforces Beta Round #12 (Div 2 Only) D. Ball sort/map
D. Ball Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/12/D D ...
- Codeforces Testing Round #12 C. Subsequences 树状数组维护DP
C. Subsequences Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/probl ...
- Codeforces Testing Round #12 B. Restaurant 贪心
B. Restaurant Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/problem ...
- Codeforces Testing Round #12 A. Divisibility 水题
A. Divisibility Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/probl ...
- Educational Codeforces Round 12 E. Beautiful Subarrays 预处理+二叉树优化
链接:http://codeforces.com/contest/665/problem/E 题意:求规模为1e6数组中,连续子串xor值大于等于k值的子串数: 思路:xor为和模2的性质,所以先预处 ...
- select cast(round(12.5,2) as numeric(5,2))
http://www.jb51.net/article/74284.htm 解释: round()函数,是四舍五入用,第一个参数是我们要被操作的数据,第二个参数是设置小数四舍五入的精度. )--32. ...
随机推荐
- AtCoder Beginner Contest 302 H. Ball Collector 题解 可撤销并查集
为了更好的阅读体验,请单击这里 AtCoder Beginner Contest 302 H. Ball Collector 题意跳过. 可以视作将 \(a_i, b_i\) 之间连了一条边,然后 \ ...
- Linux 内核:RCU机制与使用
Linux 内核:RCU机制与使用 背景 学习Linux源码的时候,发现很多熟悉的数据结构多了__rcu后缀,因此了解了一下这些内容. 介绍 RCU(Read-Copy Update)是数据同步的一种 ...
- Linux设备模型:3、Uevent
作者:wowo 发布于:2014-3-10 20:39 分类:统一设备模型 http://www.wowotech.net/device_model/uevent.html Uevent Uevent ...
- Python使用Argparse读取命令参数
python编写的脚本需要通过命令参数来做一些参数配置.本文将介绍如何使用argparse来解析命令行参数.这种方法相对于sys.args的方式会简单很多. 通过以下的脚本来构建一个简单的配置解析器, ...
- 什么是Selenium Grid?如何搭建Selenium Grid?
标签(空格分隔): 测试架构 什么是测试基础架构? 测试基础架构指的是,执行测试的过程中用到的所有基础硬件设施以及相关的软件设施.因此,我们也把测试基础架构称之为广义的测试执行环境.通常来讲,测试基础 ...
- JS--正则表达式--手稿
- 网易数帆开源贡献获业界肯定,轻舟API网关获OSCAR尖峰开源技术创新奖
2020年10月16日,由中国信息通信研究院主办的"2020开源产业大会"在北京线下与线上同步召开,主办方在会上公布了"OSCAR尖峰开源奖项"各个奖项的评选结 ...
- 如何在 XAMPP 中使用 不同的 PHP 版本?
你有没有碰到这种情况,你工作的项目需要的是PHP8,而你自己的项目需要的是PHP7,而你又特别钟爱于XAMPP,奈何它却不能自由切换PHP版本,下面就讲下本人在用的方法将PHP7更新到PHP8,可以通 ...
- MySql创建事件、计划、定时运行
CREATE EVENT IF NOT EXISTS check_timeout_eventON SCHEDULE EVERY 30 MINUTEDOBEGIN UPDATE safetyApp_in ...
- 基于Java+SpringBoot+Vue宠物咖啡馆平台设计和实现
\n文末获取源码联系 感兴趣的可以先收藏起来,大家在毕设选题,项目以及论文编写等相关问题都可以给我加好友咨询 系统介绍: 随着信息技术在管理上越来越深入而广泛的应用,管理信息系统的实施在技术上已逐步成 ...