HDU 4950 Monster(公式) HDU 4950 Monster

HDU 4950 Monster(公式)

HDU 4950 Monster

HDU 4950 Monster

题目链接

题意:给定怪兽血量h,你攻击力a。怪物回血力b,你攻击k次要歇息一次,问是否能杀死怪兽

思路:签到题,注意最后一下假设打死了怪,那么怪就不会回血了

思路:

#include <cstdio>
#include <cstring>

typedef long long ll;
ll h, a, b, k;

bool solve() {
    if (a >= h) return true;
    if (b >= a) return false;
    if (h - (k - 1) * a + b * (k - 1) <= a) return true;
    ll s = -a * k + b * (k + 1);
    if (s >= 0) return false;
    return true;
}

int main() {
    int cas = 0;
    while (~scanf("%I64d%I64d%I64d%I64d", &h, &a, &b, &k) && h) {
	printf("Case #%d: ", ++cas);
	printf("%s
", solve() ? "YES" : "NO");
    }
    return 0;
}