【Codeforces 903B】The Modcrab

【链接】 我是链接,点我呀:)
【题意】

【题解】

显然如果对方一次攻击能打死你。 那么你不能对他攻击了。必须加血。其他时候都只要攻击就可以了。 但也不一定非得加血。 因为有时候可以“绝杀”,就是虽然对方能打死你,但你也能在这回合打死对方。 这种情况就不用加血了。

【代码】

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

int h1,a1,c1;
int h2,a2;
vector<string> ans;

int main()
{
    ios::sync_with_stdio(0),cin.tie(0);
    cin >> h1 >> a1 >> c1;
    cin >> h2 >> a2;
    while (h2>0){
        if (h1<=a2){
            if (h2-a1<=0){
                h2-=a1;
                ans.push_back("STRIKE");
            }else{
                h1+=c1;
                ans.push_back("HEAL");
            }
        }else{
            ans.push_back("STRIKE");
            h2-=a1;
        }
        if (h2<=0) break;
        h1-=a2;
    }
    cout<<ans.size()<<endl;
    for (string x:ans){
        cout<<x<<endl;
    }
    return 0;
}
原文地址:https://www.cnblogs.com/AWCXV/p/9744904.html