- 西中经开联校 - 第 11 场周赛
【题解】西中经开联校 - 第 11 场周赛
- @ 2025-3-31 10:54:13
偶数场周赛较难,奇数场周赛较易。
T1 TooY0ung 的数字游戏
难度:没有难度,简单数学计算。
算法:数学,模拟。
子任务 ( 分):由于 ,题目中又保证了 ,所以 TooY0ung 的数字永远无法超过 TooSimple ,输出 即可。
子任务 ( 分):保证了 ,,所以直接计算 即可。
子任务 ( 分):满分做法除了无解情况,其实就是计算 ,需要注意如果可以整除,答案要 ,不能整除向上取整就好。
C++ 代码:
#include <bits/stdc++.h>
using namespace std;
int x, y, a, b;
int main()
{
cin >> x >> y >> a >> b;
if (a <= b) puts("-1");
else
{
if ((y - x) % (a - b) == 0) cout << (y - x) / (a - b) + 1 << endl;
else cout << (y - x + a - b - 1) / (a - b) << endl;
}
return 0;
}
T2 TooY0ung 的美食之旅
难度:循环,条件判断。
算法:数学,模拟。
子任务 ( 分):由于输入的全部都是 ,所以输出 就好了。
子任务 ( 分):没有 的话只需要关注数字发生了几次改变即可。
子任务 ( 分):其实只要在代码中统计有没有 出现,记录开心不开心即可,用一些变量存储以上各种情况,很容易实现代码。
C++ 代码:
#include <bits/stdc++.h>
using namespace std;
int n, x, no2, happy, unhappy, ans;
int main()
{
cin >> n;
for (int i = 1; i <= n; i ++ )
{
cin >> x;
if (x != 2 && no2 == 0)
{
no2 = 1;
if (x == 1) unhappy = 1;
else happy = 1;
}
if (no2 == 1 && x == 2) continue;
if (no2 == 1 && happy == 1 && x == 1 && unhappy == 0)
happy = 0, unhappy = 1, ans ++ ;
else if (no2 == 1 && unhappy == 1 && x == 3 && happy == 0)
unhappy = 0, happy = 1, ans ++ ;
}
cout << ans << endl;
return 0;
}
T3 TooY0ung 的 WrongAnswer
难度:循环、字符串。
算法:字符串处理。
子任务 ( 分):只有小写字母只要查找是否有小写的 就行了,这里可以直接用 find 函数就行。
子任务 ( 分):只有大写字母就需要找一下 。
子任务 ( 分):满分做法其实就是把字母全变大写或者小写,找 “WRONGANSWER” 和 “wronganswer” 即可,在看同学们代码的时候,有一些不正确的写法被我的类似于 “WWRONGANSWER” 数据卡掉了,同学们可以课下再改一下。
C++ 代码:
#include <bits/stdc++.h>
using namespace std;
string s;
string wa = "wronganswer";
int main()
{
cin >> s;
int len = (int)s.size();
for (int i = 0; i < len; i ++ )
if (s[i] >= 'A' && s[i] <= 'Z') s[i] += 'a' - 'A';
if (s.find("wronganswer") != s.npos) puts("Yes");
else puts("No");
return 0;
}
T4 TooY0ung 的等差数列
难度:用学生的话说,可以叫智商测验题。
算法:。
只说正解吧:正解就是输出 就行,因为题目中写了数列长度大于等于 ,所以可以长度为 。
C++ 代码:
#include <bits/stdc++.h>
using namespace std;
int x;
int main()
{
cin >> x;
cout << 1 << endl;
cout << x << endl;
return 0;
}
0 comments
No comments so far...