偶数场周赛较难,奇数场周赛较易。

T1 TooY0ung 的数字游戏

难度:没有难度,简单数学计算。

算法:数学,模拟。

子任务 113030 分):由于 a<ba<b,题目中又保证了 x<yx<y,所以 TooY0ung 的数字永远无法超过 TooSimple ,输出 1-1 即可。

子任务 223030 分):保证了 a=2a=2b=1b=1,所以直接计算 yx+1y−x+1 即可。

子任务 334040 分):满分做法除了无解情况,其实就是计算 (yx)/(ab)(y-x)/(a−b),需要注意如果可以整除,答案要 +1+ 1,不能整除向上取整就好。

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 的美食之旅

难度:循环,条件判断。

算法:数学,模拟。

子任务 113030 分):由于输入的全部都是 33,所以输出 00 就好了。

子任务 223030 分):没有 22 的话只需要关注数字发生了几次改变即可。

子任务 334040 分):其实只要在代码中统计有没有 22 出现,记录开心不开心即可,用一些变量存储以上各种情况,很容易实现代码。

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

难度:循环、字符串。

算法:字符串处理。

子任务 113030 分):只有小写字母只要查找是否有小写的 wronganswerwronganswer 就行了,这里可以直接用 find 函数就行。

子任务 223030 分):只有大写字母就需要找一下 WRONGANSWERWRONGANSWER

子任务 334040 分):满分做法其实就是把字母全变大写或者小写,找 “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 的等差数列

难度:用学生的话说,可以叫智商测验题。

算法:。

只说正解吧:正解就是输出 XX 就行,因为题目中写了数列长度大于等于 11,所以可以长度为 11

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