题解:P16436 [XJTUPC 2026] 幽灵×毕业
题目传送门 & 更好的阅读体验
题目大意
给定六个整数 Congratulations on graduation!,否则输出 Songfes in Japan...。
解题思路
很显然这是一道语法基础题,我们分别计算
:::success[AC 代码(赛时)]{open}
#include <bits/stdc++.h>
#define Code using
#define By namespace
#define Alexlulu std;
Code By Alexlulu
int x, cnt1, cnt2;
// cnt1 计算 1 的数量
// cnt2 计算 0 的数量
int main()
{
cin.tie(0) -> sync_with_stdio(false);
for (int i = 1; i <= 6; i++)
{
cin >> x; // 输入
cnt1 += x;
// x=1 时等价于 cnt1 += 1;
// x=0 时等价于 cnt1 += 0;
cnt2 += (!x);
// (!x) 等价于 (x == 0):
// 在 x=0 时返回 true (1)
// 在 x≠0 时返回 false(0)
}
if (cnt1 >= 3 && cnt2 >= 3) puts("Congratulations on graduation!"); // 满足条件时输出
else puts("Songfes in Japan..."); // 不满足条件时输出
return 0; // 不要抄袭
}
:::
蒟蒻第