4950 Monster

Monster

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 52 Accepted Submission(s):
29

Problem 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<=h,a,b,k <=10^9).

 
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
 
Source
 
Recommend
hujie

2014多校8 第六题 1006

大意:主角打boss,boss有h血,每回合主角打a血,然后boss回b血。主角打k回合后需要休息1回合,boss也回血。问主角能否打死boss。

题解:

惊天大水题。不过一开始一大堆人wa,我还怕了好久。认真分析,其实是很容易1A的。

我们分3种情况:

1.一刀砍死:

h-a < 1

2.连砍k刀将其砍死:

h-(a-b)*(k-1)-a < 1

3.连砍k刀之后休息一回合,怪的血量减少

h-(a-b)*(k)+b < h

这三种情况就是全部了,其中任意一个为true,就能砍死怪。

题目说可以在没砍到k刀就停下来休息,其实是不优的,要不就一刀砍死,要不就连砍k刀再休息,要是砍不到k刀就休息还能削弱怪物的血,连砍k刀肯定更能削弱怪物的血,这个情况归类到情况3中。

实在是太水了,居然只问yes和no,至少也问一下多少回合砍死啊!

代码:

 //#pragma comment(linker, "/STACK:102400000,102400000")
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
#define ll long long
#define usint unsigned int
#define mz(array) memset(array, 0, sizeof(array))
#define minf(array) memset(array, 0x3f, sizeof(array))
#define REP(i,n) for(i=0;i<(n);i++)
#define FOR(i,x,n) for(i=(x);i<=(n);i++)
#define RD(x) scanf("%d",&x)
#define RD2(x,y) scanf("%d%d",&x,&y)
#define RD3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define WN(x) printf("%d\n",x);
#define RE freopen("D.in","r",stdin)
#define WE freopen("1biao.out","w",stdout) int main() {
int cas=, ans;
ll h,a,b,k;
while(scanf("%I64d%I64d%I64d%I64d",&h,&a,&b,&k)!=EOF) {
if(h== && a== && b== && k==)break;
if(h-a<)ans=;
else if(h-(a-b)*(k-)-a<)ans=;
else {
if(h-(a-b)*(k)+b>=h)ans=;
else ans=;
}
if(ans==)printf("Case #%d: NO\n",cas++);
else printf("Case #%d: YES\n",cas++);
}
return ;
}

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

  1. HDU 4950 Monster (水题)

    Monster 题目链接: http://acm.hust.edu.cn/vjudge/contest/123554#problem/I Description Teacher Mai has a k ...

  2. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  3. ACM :漫漫上学路 -DP -水题

    CSU 1772 漫漫上学路 Time Limit: 1000MS   Memory Limit: 131072KB   64bit IO Format: %lld & %llu Submit ...

  4. ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)

    1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 154  Solved: 112[ ...

  5. [poj2247] Humble Numbers (DP水题)

    DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The se ...

  6. gdutcode 1195: 相信我这是水题 GDUT中有个风云人物pigofzhou,是冰点奇迹队的主代码手,

    1195: 相信我这是水题 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 821  Solved: 219 Description GDUT中有个风云人 ...

  7. BZOJ 1303 CQOI2009 中位数图 水题

    1303: [CQOI2009]中位数图 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 2340  Solved: 1464[Submit][Statu ...

  8. 第十一届“蓝狐网络杯”湖南省大学生计算机程序设计竞赛 B - 大还是小? 字符串水题

    B - 大还是小? Time Limit:5000MS     Memory Limit:65535KB     64bit IO Format: Description 输入两个实数,判断第一个数大 ...

  9. ACM水题

    ACM小白...非常费劲儿的学习中,我觉得目前我能做出来的都可以划分在水题的范围中...不断做,不断总结,随时更新 POJ: 1004 Financial Management 求平均值 杭电OJ: ...

  10. CF451C Predict Outcome of the Game 水题

    Codeforces Round #258 (Div. 2) Predict Outcome of the Game C. Predict Outcome of the Game time limit ...

随机推荐

  1. 【bzoj3624】Apio2008—免费道路

    http://www.lydsy.com/JudgeOnline/problem.php?id=3624 (题目链接) 题意 给出一张无向图,其中有0类边和1类边.问能否构成正好有K条0类边的生成树, ...

  2. BZOJ2426 [HAOI2010]工厂选址

    Description 某地区有m座煤矿,其中第i号矿每年产量为ai吨,现有火力发电厂一个,每年需用煤b吨,每年运行的固定费用(包括折旧费,不包括煤的运费)为h元,每吨原煤从第i号矿运到原有发电厂的运 ...

  3. XHTML与HTML的区别

    XHTML:可扩展超文本标记语言,是一种置标语言,表现方式与超文本标记语言(HTML)类似,不过语法上更加严格. 参考:http://baike.baidu.com/search/word?word= ...

  4. linux最常用的20条命令

    玩过Linux的人都会知道,Linux中的命令的确是非常多,但是玩过Linux的人也从来不会因为Linux的命令如此之多而烦恼,因为我们只需要掌握我们最常用的命令就可以了.当然你也可以在使用时去找一下 ...

  5. Bzoj3663/4660 CrazyRabbit

    题意:给定平面上一个圆和一堆圆外的点,要求选出尽可能多的点使得它们之间两两连线都不和圆相交.保证任意两点连线不和圆相切.点数<=2000 这题是很久以前在某张课件上看见的.看了题解还搞了三小时, ...

  6. C# 获取当前,相对,绝对路径

    一.C#获取当前路径的方法: 1. System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName -获取模块的完整路径. 2. ...

  7. C#基础之数组排序,对象大小比较

    从个小例子开始: 1 2 3 int[] intArray = new int[]{2,3,6,1,4,5}; Array.Sort(intArray); Array.ForEach<int&g ...

  8. scala break & continue

    Scala没有提供break和continue,我们可以自己实现一个,参考例子: import util.control.Breaks._ object BreakDemo { def main(ar ...

  9. UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-13: ordinal not i│ n range(128)

    python保持网页文件遇到的错误,归根结底还是编码问题,改一下要保存的数据为utf-8就好了. 如下最简单: import sys reload(sys) sys.setdefaultencodin ...

  10. what's the CRSF ??

    What's CSRF attack ? CSRF(" Cross-site request forgery!" 跨站请求伪造)    用实例讲原理: 我们假设一个银行网站A,一个 ...