题目链接:

pid=4950http://acm.hdu.edu.cn/showproblem.php?pid=4950">http://acm.hdu.edu.cn/showproblem.php?pid=4950

Monster

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 220    Accepted Submission(s): 92
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

题意:给出怪兽的血量h,玩家每回合造成的伤害a,每一回合结束后怪兽会回血量b,玩家在连续攻击k回合后须歇息一次(也能够在K回合之前的随意回合歇息)。推断玩家是否能杀死怪兽!



思路:贪心。必定是打了K回合后再歇息!详细见代码解析;




代码例如以下:
#include<cstdio>
typedef __int64 LL;
int main()
{
LL h,a,b,k;
LL cas = 0;
while(~scanf("%I64d%I64d%I64d%I64d",&h,&a,&b,&k))
{
if(h==0 && a==0 && b==0 && k==0)
break;
printf("Case #%I64d: ",++cas);
if(h <= a)//第一回合怪兽就死亡
{
printf("YES\n");
continue;
}
if((k-1)*(-a+b)-a+h <= 0)//前K回合怪兽死亡
{
printf("YES\n");
continue;
}
if(k*(-a+b)+b < 0)//每K回合后怪兽的血量在降低
{
printf("YES\n");
continue;
}
printf("NO\n");
}
return 0;
}

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMjg2MDA2Mw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">

hdu 4950 Monster(数学题,多校8)的更多相关文章

  1. HDU 4950 Monster(公式)

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

  2. HDU 4950 Monster (水题)

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

  3. HDU 4950 Monster

    题目链接 题意:有一个怪物的血量为h,人攻击怪物,每回合可以杀掉a滴血,再回b滴血,k个回合之后人会休息一回合,即人不攻击而怪物回b滴血,问能否杀死.翻译过来就是给定一个数h,每轮可以先减a再加b,k ...

  4. hdu 5587 Array 数学题

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

  5. hdu 4950 打怪

    http://acm.hdu.edu.cn/showproblem.php?pid=4950 给定怪兽血量h,你攻击力a,怪物回血力b,你攻击k次要休息一次,问能否杀死怪兽 特判一次打死怪兽的情况和第 ...

  6. HDU 6467 简单数学题 【递推公式 && O(1)优化乘法】(广东工业大学第十四届程序设计竞赛)

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6467 简单数学题 Time Limit: 4000/2000 MS (Java/Others)    M ...

  7. HDU 4901(杭电多校训练#3 1005题)The Romantic Hero(DP)

    题目地址:HDU 4901 这题没想到最后竟然可以做出来.. .. 这题用了两次DP,先从前往后求一次异或的.再从后往前求一次与运算的. 各自是 1:求异或的时候,定义二维数组huo[1000][10 ...

  8. 【单调栈】hdu 6319 杭电多校Problem A. Ascending Rating

    http://acm.hdu.edu.cn/showproblem.php?pid=6319 从后往前更新,维护一个递减单调栈(队列) 最近很多题都是单调栈... #define _CRT_SECUR ...

  9. HDU 3979 Monster (贪心排序)

    Monster Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Su ...

随机推荐

  1. springmvc下载那些事

    文件的上传下载一般在项目中还是非常实用的,此处专门整理一下文件的下载,至于文件的上传实现将在后续中补上.文件的下载多用于模板文件的下载,这在项目中用的还是挺多的.今天用到了就整理出来了,以供搬运工们借 ...

  2. poj-1163 动态规划

    这道题目并不能直接使用递归,因为 7(1) 7(1)         7(1) 7(1)      7(2)         7(1) 7(1)       7(3)         7(3)    ...

  3. 用python的Requests库模拟http请求

    一.先了解几个重要的http请求头或响应头信息 Request Headers: Host: 描述请求将被发送的目的地,包括,且仅仅包括域名和端口号. Origin: 说明请求从哪里发起的,包括,且仅 ...

  4. 13. OPTIMIZER_TRACE

    13. OPTIMIZER_TRACE OPTIMIZER_TRACE表提供由跟踪语句的优化程序跟踪功能生成的信息. 要启用跟踪,请使用optimizer_trace系统变量. 有关详细信息,请参阅M ...

  5. python基础(二) —— 流程控制语句

    编程语言中的流程控制语句分为以下几类: 顺序语句 分支语句 循环语句 其中顺序语句不需要单独的关键字来控制,就是按照先后顺序一行一行的执行,不需要特殊的说明. 下面主要是 分支语句 和 循环语句的说明 ...

  6. python 连接docker

    发现15年写过的一小段,先mark一下,后续玩儿起来 import docker c = docker.Client(base_url='unix://var/run/docker.sock',ver ...

  7. tomcat官网改版后下载方式

    位于disk/tomcat目录下 http://archive.apache.org/dist/tomcat/ 具体例如:http://archive.apache.org/dist/tomcat/t ...

  8. SSM整合shiro

    采用maven构建项目 1pom.xml中加入shiro依赖 <!-- shiro --> <dependency> <groupId>org.apache.shi ...

  9. my97datepicker插件日期值改变事件 等同于input的onchang()时间

    官网Demo地址http://www.my97.net/demo/index.htm <input type="text" class="Wdate" v ...

  10. mysql 常用命令(二)

    1.创建数据库,并制定默认的字符集是utf8. CREATE DATABASE IF NOT EXISTS yourdbname DEFAULT CHARSET utf8 COLLATE utf8_g ...