题解:P8534 「Wdoi-2」比赤色更红的梦

· · 题解

解题思路

根据题意模拟:开始时有 2 个残机,再根据 x 通过指定关卡与 s 达到对应分数分别累加残机。可以使用布尔表达式简化代码。

参考代码

#include <bits/stdc++.h>
using namespace std;

using ll=long long;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T;
    cin>>T;
    while(T--)
    {
        ll x,s;
        cin>>x>>s;
        cout<<2+(x>=3)+(x>=5)+(s>=10000000)+(s>=20000000)+(s>=40000000)+(s>=60000000)<<'\n';
    }
    return 0;
}