前言:
觉得这个比赛很有意思的,都是暴力题,涉及一些细节,难度比较适合刚学编程语言的,可以很好的锻炼基础还有手速,最后两题也是比较有意思,之后也准备更新atc的比赛题解和洛谷的一些高质量比赛题解(算法网瘾就是想参加各种比赛)
如果觉得有帮助,或者觉得我写的好,可以点个赞或关注,也可以看看我的一些其他文章,我之后也会更新一些基础算法详细解释
比赛链接:
【LGR-196-Div.4】洛谷入门赛 #26 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
目录
题A:
B4017 [语言月赛 202408] 相识于 2016 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
题目大意和解题思路:
2018年8月是认识的第一个月,现在输入年和月,问认识了几个月
不需要管理月份大小的,只要月份小于8,那么表示肯定不是同一年
需要注意的是8月是第一个月,也就是7月是第0个月,减7就可以了
所以res = (x - 2016) * 12 + (y - 7)
代码(C++):
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(0);
int x, y;
std::cin >> x >> y;
int res = (x - 2016) * 12 + (y - 8) + 1;
std::cout << res << std::endl;
}
代码(Python):
def main():
x, y = map(int, input().split())
res = (x - 2016) * 12 + (y - 7)
print(res)
题B:
B4018 [语言月赛 202408] 游戏与共同语言 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
题目大意和解题思路:
- 胜局数高者排名靠前
- 若胜局数相同,净胜数高者排名靠前
- 若净胜数仍相同,平局记录低者排名靠前
- 不存在平局记录仍相同的情况
简单的判断就行,一个一个写就不会出错了
代码(C++):
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(0);
int wa, ca, ta, wb, cb, tb;
std::cin >> wa >> ca >> ta >> wb >> cb >> tb;
bool f = 0;
if (wa == wb) {
if (ca == cb) {
if (ta > tb) {
f = 1;
} else {
f = 0;
}
} else if (ca > cb) {
f = 1;
} else {
f = 0;
}
} else if (wa > wb) {
f = 1;
} else {
f = 0;
}
if (f) {
std::cout << "A" << std::endl;
} else {
std::cout << "B" << std::endl;
}
}
代码(Python):
def main():
wa, ca, ta = map(int, input().split())
wb, cb, tb = map(int, input().split())
f = 0
if wa == wb:
if ca == cb:
if ta > tb:
f = 1
else:
f = 0
elif ca > cb:
f = 1
else:
f = 0
elif wa > wb:
f = 1
else:
f = 0
if f == 1:
print("A")
else:
print("B")
题C:
B4019 [语言月赛 202408] 皆与生物有缘 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
题目大意和解题思路:
本题就是求两名老师评分总分的平均值,向上取整
向上取整,加上除数减一就行了,这里的除数是2,那么就在总数上加一
代码(C++):
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(0);
int n, x1 = 0, x2 = 0;
std::cin >> n;
int x;
for (int i = 0; i < n; i++) {
std::cin >> x;
x1 += x;
}
for (int i = 0; i < n; i++) {
std::cin >> x;
x2 += x;
}
int res = (x1 + x2 + 1) / 2;
std::cout << res << std::endl;
}
代码(Python):
def main():
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int,

最低0.47元/天 解锁文章
421

被折叠的 条评论
为什么被折叠?



