题解 | 回合制游戏

#include <iostream>
using namespace std;

int main() {
    long long hp, normal, buffed;
    cin >> hp >> normal >> buffed;
    if (normal * 2 >= buffed) { // 一直用normal就行
        if (hp % normal > 0) {
            cout << hp / normal + 1 << endl;
        } else {
            cout << hp / normal << endl;
        }
    } else { // 尽量用buffed
        long long left = hp % buffed;
        if (left > normal) {
            cout << (hp / buffed) * 2 + 2 << endl;
        } else if (left == 0) {
            cout <<  (hp / buffed) * 2 << endl;
        } else {
            // 0< left <= normal < buffed/2
            cout << (hp / buffed) * 2 + 1 << endl;
        }
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

09-17 10:53
四川大学 C++
loveTy:你这些技能对大厂没用,而且四川大学因为之前地铁那个事件上了不少民营企业的黑名单。 去试一试国企,他们的黑名单没民营那么狠
点赞 评论 收藏
分享
求过求过
xianwu543:华为不是线下面试吗?你怎么就面完了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务