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. Spring中的Autowired注解和Resource注解的区别

    1.所属jar包不同,Autowired是Spring中的Resource是JSR-250规范定义的注解

  2. 【poj3241】 Object Clustering

    http://poj.org/problem?id=3241 (题目链接) MD被坑了,看到博客里面说莫队要写曼哈顿最小生成树,我就写了一个下午..结果根本没什么关系.不过还是把博客写了吧. 转自:h ...

  3. PHP数组/Hash表的实现/操作、PHP变量内核实现、PHP常量内核实现 - [ PHP内核学习 ]

    catalogue . PHP Hash表 . PHP数组定义 . PHP变量实现 . PHP常量实现 1. PHP Hash表 0x1: 基本概念 哈希表在实践中使用的非常广泛,例如编译器通常会维护 ...

  4. siege详解

    简介 siege是一款HTTP/FTP负载测试和基准压测工具   Download http://download.joedog.org/siege/siege-latest.tar.gz   安装 ...

  5. eclipse+SVN文件只显示版本号,不显示时间和作者解决办法

    SVN默认是显示提交次数的 改成这样 就可以了...

  6. 在Ubuntu上如何往fcitx里添加输入法

    Ubuntu 16.04引入了一个新的包管理工具apt, 用法与apt-get类似. 在终端用apt搜索fcitx支持的输入法 apt search fcitx All Fcitx related p ...

  7. python pep8

    有这个自动的规范检查工具 pip install pep8 具体使用不说了 ==. 百度一堆  http://blog.sae.sina.com.cn/archives/4781  看这里

  8. spring-data-jpa 的@Query注解的使用

    // ------------------------------------ 使用 @Query 注解 // 没有参数的查询 @Query("select p from Person p ...

  9. lunix的查看Tomcat目录下日志的快速操作

    可以使用cd命令,cd命令的功能是切换到指定的目录: 命令格式:cd [目录名] 有几个符号作为目录名有特殊的含义: "/"代表根目录. ".."代表上一级目录 ...

  10. 用css进行布局

     用css进行布局 一,开始布局的注意事项 1.作为最佳实践,应把html(内容)和css(显示)分离: 2.网站设计主要有两大类型:固定宽度(基于像素)和响应式(也称流式,使用百分数定义) 二,构建 ...