Monster

题目链接:

http://acm.hust.edu.cn/vjudge/contest/123554#problem/I

Description


Teacher Mai has a kingdom. A monster has invaded this kingdom, and Teacher Mai wants to kill it.
Monster initially has h HP. And it will die if HP is less than 1.
Teacher Mai and monster take turns to do their action. In one round, Teacher Mai can attack the monster so that the HP of the monster will be reduced by a. At the end of this round, the HP of monster will be increased by b.
After k consecutive round's attack, Teacher Mai must take a rest in this round. However, he can also choose to take a rest in any round.
Output "YES" if Teacher Mai can kill this monster, else output "NO".

Input


There are multiple test cases, terminated by a line "0 0 0 0".
For each test case, the first line contains four integers h,a,b,k(1

Output


For each case, output "Case #k: " first, where k is the case number counting from 1. Then output "YES" if Teacher Mai can kill this monster, else output "NO".

Sample Input


5 3 2 2
0 0 0 0

Sample Output


Case #1: NO


##题意:

怪物有h点血,每回合可以打a点,打完如果没死可以恢复b点.
每k轮至少休息一次. 求是否能打死怪物.


##题解:

考虑长远的情况肯定是 a*k - b*(k+1) > 0 ?.
但是还有一些特殊一点的情况:
如果一次就能打死怪物,即 a >= h , 无论b多大都不影响.
贪心的思路肯定是在第k+1轮才休息. 那么在休息之前能打死,那在休息之后可能就不满足上述不等式.
即 a*k - b*(k-1) >= h
WA了一发:如果第k轮打死,怪物是不会回血的,所以是减去b*(k-1).
水题也还须考虑全面. 切忌盲目提交.


##代码:
``` cpp
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define LL long long
#define eps 1e-8
#define maxn 101000
#define mod 100000007
#define inf 0x3f3f3f3f
#define mid(a,b) ((a+b)>>1)
#define IN freopen("in.txt","r",stdin);
using namespace std;

int main(int argc, char const *argv[])

{

//IN;

LL h,a,b,k;
int ca = 1;
while(scanf("%lld %lld %lld %lld", &h,&a,&b,&k) != EOF && (h||a||b||k))
{
if(a >= h) printf("Case #%d: YES\n", ca++);
else if(a*k-b*(k-1) >= h) printf("Case #%d: YES\n", ca++);
else if(a*k-b*(k+1) > 0) printf("Case #%d: YES\n", ca++);
else printf("Case #%d: NO\n", ca++);
} return 0;

}

HDU 4950 Monster (水题)的更多相关文章

  1. HDU 4950 Monster(公式)

    HDU 4950 Monster 题目链接 题意:给定怪兽血量h,你攻击力a.怪物回血力b,你攻击k次要歇息一次,问是否能杀死怪兽 思路:签到题,注意最后一下假设打死了怪,那么怪就不会回血了 思路: ...

  2. hdu 5210 delete 水题

    Delete Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5210 D ...

  3. hdu 4950 Monster(数学题,多校8)

    题目链接:pid=4950http://acm.hdu.edu.cn/showproblem.php?pid=4950">http://acm.hdu.edu.cn/showprobl ...

  4. hdu 1251 (Trie水题)

    统计难题 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131070/65535 K (Java/Others)Total Submi ...

  5. HDU 5703 Desert 水题 找规律

    已知有n个单位的水,问有几种方式把这些水喝完,每天至少喝1个单位的水,而且每天喝的水的单位为整数.看上去挺复杂要跑循环,但其实上,列举几种情况之后就会发现是找规律的题了= =都是2的n-1次方,而且这 ...

  6. HDU 4493 Tutor 水题的收获。。

    题目: http://acm.hdu.edu.cn/showproblem.php?pid=4493 题意我都不好意思说,就是求12个数的平均数... 但是之所以发博客,显然有值得发的... 这个题最 ...

  7. hdu 4802 GPA 水题

    GPA Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4802 Des ...

  8. hdu 4493 Tutor 水题

    Tutor Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4493 D ...

  9. hdu 5495 LCS 水题

    LCS Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5495 Descr ...

随机推荐

  1. hdu 4937 Lucky Number

    虽然算法清晰的不能再清晰,但是实现总是边角料错这错那. 题目大意: 给出n,找出一些进制,使得n在该进制下仅为3,4,5,6表示 解题思路: 首先,4-10000进制直接枚举计算出每一位 此外,最多只 ...

  2. UVa 11168 (凸包+点到直线距离) Airport

    题意: 平面上有n个点,求一条直线使得所有点都在直线的同一侧.并求这些点到直线的距离之和的最小值. 分析: 只要直线不穿过凸包,就满足第一个条件.要使距离和最小,那直线一定在凸包的边上.所以求出凸包以 ...

  3. fastdfs-client-java 文件上传

    FastDFS是一个开源的轻量级分布式文件系统,它对文件进行管理,功能包括:文件存储.文件同步.文件访问(文件上传.文件下载)等,解决了大容量存储和负载均衡的问题.特别适合以文件为载体的在线服务,如相 ...

  4. symbolicatecrash位置

    symbolicatecrash是一个隐藏工具,它在我的Mac中的具体路径如下(Xcode6.1.app请换成你的Xcode名称) /Applications/Xcode6.1.app/Content ...

  5. Java [Leetcode 66]Plus One

    题目描述: Given a non-negative number represented as an array of digits, plus one to the number. The dig ...

  6. Java [Leetcode 70]Climbing Stairs

    题目描述: You are climbing a stair case. It takes n steps to reach to the top. Each time you can either ...

  7. Java [leetcode 8] String to Integer (atoi)

    问题描述: Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input ...

  8. 【转】 CATransform3D 矩阵变换之立方体旋转实现细节

    原文网址:http://blog.csdn.net/ch_soft/article/details/7351896 第一部分.前几天做动画,使用到了CATransform3D ,由于没有学过计算机图形 ...

  9. Dev gridControl 添加表标题

    1.OptionsView ->ShowViewCaption = True 2.ViewCaption = "标题"

  10. Sql中判断“数据库"、"表"、"临时表"、"存储过程"和列”是否存在

    --判断数据库是否存在   IF EXISTS (SELECT * FROM MASTER..sysdatabases WHERE NAME = ''库名'')      PRINT ''exists ...