题解 P1785 【漂亮的绝杀】

· · 题解

安利博客

小伙伴做题时会对题意不理解吗?

我先解释一下题意。

连击最多只能打两下。概率是没有用的。这里直接算就行。

先用“||”判断数据有没有锅

再用连击两下和boss比较

(z<<1)<=>x

看看可以不可以杀死

输出

Yes或No

再用x和z比较

z<=>x

一下死就直接计算即可。

if(z>x)
        {
            if(int(z*0.33)+y>=315){
                cout<<"Great"<<endl;
            }
            else if(int(z*0.5)+y>=315){
                cout<<"Eh.."<<endl<<"OK"<<endl;
            }
            else if(int(z+y>=315){
                cout<<"Oh.."<<endl<<"Oh.."<<endl<<"Yes , If he can get 5-star."<<endl;
            }
            else {
                cout<<"No"<<endl<<"No"<<endl<<"No"<<endl;
            }
        }

两下就乘2。

{
            if(2*int(z*0.33)+y>=315){
                cout<<"Great"<<endl;
            }
            else if(2*int(z*0.5)+y>=315){
                cout<<"Eh.."<<endl<<"OK"<<endl;
            }
            else if(2*z+y>=315){
                cout<<"Oh.."<<endl<<"Oh.."<<endl<<"Yes , If he can get 5-star."<<endl;
            }
            else {
                cout<<"No"<<endl<<"No"<<endl<<"No"<<endl;
            }

注意换行。

计算时要强制转int

全篇的if/else判断即可

代码有锅 勿抄。QuQ.

#include<iostream>
#include<cstdio>
#include<algorithm>
#define INF 0x7fffffff
#define ll long long
#define IL inline
#define R register
using namespace std;
int x,y,z;

int main()
{
    cin>>x>>y>>z; 
    if(y<=0||y>315||y>=x||x>1800||z>=1000||z<=100)
    {
        cout<<"Wrong Data"<<endl;
        //exit(0);结束
        return 0; 
    }
    if((z<<1)<=x)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    else {
        cout<<"No"<<endl;
        if(z>x)
        {
            if(int(z*0.33)+y>=315){
                cout<<"Great"<<endl;
            }
            else if(int(z*0.5)+y>=315){
                cout<<"Eh.."<<endl<<"OK"<<endl;
            }
            else if(int(z+y>=315){
                cout<<"Oh.."<<endl<<"Oh.."<<endl<<"Yes , If he can get 5-star."<<endl;
            }
            else {
                cout<<"No"<<endl<<"No"<<endl<<"No"<<endl;
            }
        }
        else {
            if(2*int(z*0.33)+y>=315){
                cout<<"Great"<<endl;
            }
            else if(2*int(z*0.5)+y>=315){
                cout<<"Eh.."<<endl<<"OK"<<endl;
            }
            else if(2*z+y>=315){
                cout<<"Oh.."<<endl<<"Oh.."<<endl<<"Yes , If he can get 5-star."<<endl;
            }
            else {
                cout<<"No"<<endl<<"No"<<endl<<"No"<<endl;
            }
        }
    }
    return 0;
}

by enceladus 不要变棕QwQ