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. Leetcode Odd Even Linked List

    Given a singly linked list, group all odd nodes together followed by the even nodes. Please note her ...

  2. 计算机组成原理 及CPU,硬盘,内存三者的关系

    前面提到了,电脑之父——冯·诺伊曼提出了计算机的五大部件:输入设备.输出设备.存储器.运算器和控制器. 我们看一下现在我们电脑的: 键盘鼠标.显示器.机箱.音响等等. 这里显示器为比较老的CRT显示器 ...

  3. dedecms /member/flink_main.php SQL Injection Vul

    catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 会员模块中存在的SQL注入 Relevant Link http://w ...

  4. editGrid分录表格

    waf("分录id").wafGrid("setCellEditorAllConfig", "字段名", "filteritem& ...

  5. RabbitMQ Exchange中的fanout类型

    fanout 多播 在之前都是使用direct直连类型的交换机,通过routingkey来决定把消息推到哪个queue中. 而fanout则是把拿到消息推到与之绑定的所有queue中. 分析业务,怎样 ...

  6. 一个WPF控件 诡异的MouseEvent 。

    背景: private System.Windows.Controls.Border _borderTouch; private bool _mouseDown = false;  private S ...

  7. 【Beta】Scrum02

    Info *由于28日大家事情比较多,推迟了一天 时间:2016.11.29 21:30 时长:10min 地点:大运村1号公寓5楼楼道 类型:日常Scrum会议 NXT:2016.12.01 21: ...

  8. Javascript 与正则表达式

    一.正则表达式(regular expression简称res) 二.元字符及其在正则表达式上下文中的行为 三.正则表达式的常用方法 四.与正则表达式有关的字符串对象的方法 五.常用的正则表达式的操作 ...

  9. js实现观察者模式

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  10. 查看linux机器是32位还是64位的方法

    file /sbin/init 或者 file /bin/ls/sbin/init: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dyna ...