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的更多相关文章

  1. “玲珑杯”ACM比赛 Round #12题解&源码

    我能说我比较傻么!就只能做一道签到题,没办法,我就先写下A题的题解&源码吧,日后补上剩余题的题解&源码吧!                                     A ...

  2. Codeforces Beta Round #12 (Div 2 Only)

    Codeforces Beta Round #12 (Div 2 Only) http://codeforces.com/contest/12 A 水题 #include<bits/stdc++ ...

  3. BestCoder Round #12 War(计算几何)

    War Time Limit: 8000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submis ...

  4. 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 ...

  5. 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 ...

  6. Codeforces Testing Round #12 C. Subsequences 树状数组维护DP

    C. Subsequences Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/probl ...

  7. Codeforces Testing Round #12 B. Restaurant 贪心

    B. Restaurant Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/problem ...

  8. Codeforces Testing Round #12 A. Divisibility 水题

    A. Divisibility Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/probl ...

  9. Educational Codeforces Round 12 E. Beautiful Subarrays 预处理+二叉树优化

    链接:http://codeforces.com/contest/665/problem/E 题意:求规模为1e6数组中,连续子串xor值大于等于k值的子串数: 思路:xor为和模2的性质,所以先预处 ...

  10. select cast(round(12.5,2) as numeric(5,2))

    http://www.jb51.net/article/74284.htm 解释: round()函数,是四舍五入用,第一个参数是我们要被操作的数据,第二个参数是设置小数四舍五入的精度. )--32. ...

随机推荐

  1. kubernetes安装Prometheus

    安装 在目标集群上,执行如下命令: kubectl apply -f https://github.com/512team/dhorse/raw/main/conf/kubernetes-promet ...

  2. GIS数据获取:气象数据免费下载网站

      本文对目前主要的气象数据获取网站加以整理与介绍.   本文为"GIS数据获取整理"专栏中第二篇独立博客,因此本文全部标题均由"2"开头.本文对目前主要的气象 ...

  3. K-means聚类是一种非常流行的聚类算法

    K-means聚类是一种非常流行的聚类算法,它的目标是将n个样本划分到k个簇中,使得每个样本属于与其最近的均值(即簇中心)对应的簇,从而使得簇内的方差最小化.K-means聚类算法简单.易于实现,并且 ...

  4. Linux信号量

    查看信号量 [root@localhost ~]# kill -l 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP 6) SIGABRT 7) ...

  5. vulnhub - Geisha

    vulnhub - Geisha 描述 Machine Name: Geisha Author : SunCSR Goal: Get the root flag of the target. Diff ...

  6. Mysql与Redis如何保证数据的一致性?

    问题分析: 当MySQL中的数据发生更新时,就面临一个问题,如何确保MySQL与Redis数据的一致性,我们有两个选择: 先更新MySQL,后删除(或更新)Redis 先删除(或更新)Redis,后更 ...

  7. Nginx性能调优5招35式不可不知的策略实战

    Nginx是一个高性能的HTTP和反向代理服务器,它在全球范围内被广泛使用,因其高性能.稳定性.丰富的功能以及低资源消耗而受到青睐.今天V哥从5个方面来介绍 Nginx 性能调优的具体策略,希望对兄弟 ...

  8. Python 潮流周刊第 2 季完结了,分享几项总结

    我订阅了很多的周刊/Newsletter,但是发现它们都有一个共同的毛病:就是缺乏对往期内容的整理,它们很少会对内容数据作统计分析,更没有将内容整理成合集的习惯. 在自己开始连载周刊后,我就想别开生面 ...

  9. 解决方案 | pywintypes.com_error: (-2147221005, '无效的类字符串', None, None) --Python连接CAD报错真正解决思路!

    1 背景 import pythoncom import win32com.client import math wincad = win32com.client.Dispatch("Aut ...

  10. Swift开发基础01-语法

    Hello World print("Hello World") 不用编写main函数,Swift将全局范围内的首句可执行代码作为程序入口一句代码尾部可以省略分号(;),多句代码写 ...