前言:
本文为Codeforces Round 971 (Div. 4) ABCD题的题解,包含C++,Python语言描述,觉得有帮助或者写的不错可以点个赞
比赛打了没一半突然unrated了就不是很想继续写了,早起写个题解
(之前的div3也没复盘,哎真菜)
目录
题A:
题目大意和解题思路:
给定两个整数 a 和 b (a ≤ b)。在所有可能的整数值 c (a ≤ c ≤ b) 中,找到 (c-a) + (b-c) 的最小值。
弱智题
代码(C++):
int main() {
#define int long long
std::ios::sync_with_stdio(0);
std::cin.tie(0);
int tt;
std::cin >> tt;
while (tt--) {
int a, b;
std::cin >> a >> b;
std::cout << b - a << "\n";
}
}
代码(Python):
def main():
tt = int(input())
result = []
for _ in range(tt):
a, b = map(int, input().split())
result.append(b - a)
for res in result:
print(res)
题B:
题目大意和解题思路:
你的谱面布局由 n 行和 4 列组成。因为底部的音符更接近,所以你会先处理最底部的行,最后处理最上面的行。每一行都会包含一个音符,用 '#' 表示。
对于每个音符 1, 2, ..., n,按照处理顺序,输出该音符出现的列。
从最下面开始,查找#的位置即可,注意输出的是位置不是下标
代码(C++):
int main() {
#define int long long
std::ios::sync_with_stdio(0);
std::cin.tie(0);
int tt;
std::cin >> tt;
while (tt--) {
int n;
std::cin >>