P9516 题解

· · 题解

P9516 题解

2023.08.15 留:本篇写作于 2023.08.12 16:00,本来想水篇题解,然后原题根本不给提交,于是白写了。

这题就是判断输入的五个数总和所在的范围。
从这里可以知道,灰名的对应区间为 [0,99],蓝名为 [100,119],绿名为 [120,169],橙名为 [170,229],红名为 [230,500]
接下来判断五个数的和所在区间,并输出对应颜色单词即可。

#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,f;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin>>a>>b>>c>>d>>e;
    f=a+b+c+d+e;
    if(f>=0 && f<=99) puts("Gray");
    else if(f>=100 && f<=119) puts("Blue");
    else if(f>=120 && f<=169) puts("Green");
    else if(f>=170 && f<=229) puts("Orange");
    else if(f>=230 && f<=500) puts("Red");
    return 0;
}