码迷,mamicode.com
首页 > 其他好文 > 详细

HDU 4950 Monster(公式)

时间:2014-08-15 01:33:07      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:style   http   color   os   io   ar   amp   line   

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\n", solve() ? "YES" : "NO");
    }
    return 0;
}


HDU 4950 Monster(公式),布布扣,bubuko.com

HDU 4950 Monster(公式)

标签:style   http   color   os   io   ar   amp   line   

原文地址:http://blog.csdn.net/accelerator_/article/details/38569711

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!