BZOJ系列3856《Monster》题解
来源:互联网 发布:明星语音模拟软件 编辑:程序博客网 时间:2024/06/06 03:59
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
0 0 0 0
Sample Output
Case #1: NO
英语题目,先说一下题意:
一个怪物,初始H点血,每回合可以打一下掉A点血,回合结束时怪物可以回B点血。
连续攻击K回合后,需要休息一回合。
当怪物血量小于1时死亡。
问:怪物能否死亡。
分析:
模拟。
很容易忽略情况,怪物死的情况有3种:
1.怪物第一回合就会死。
2.怪物在第K回合或第K回合前会死。
3.每K+1个回合怪物就会少一些血,直到怪物死亡。
除以上三种外,怪物都不会死亡。
(注意:数据范围!!!)
代码如下:
#include<iostream>#include<cmath>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;long long H,A,B,K,i=0;int main(){ for(;;) { scanf("%lld%lld%lld%lld",&H,&A,&B,&K); if(H==0&&A==0&&B==0&&K==0) return 0;if(A>=H||K*A-(K-1)*B>=H||K*A>(K+1)*B) printf("Case #%d: YES\n",++i);//1.第一回合就可以杀死。2.第k或第k前可以杀死。3.每k个回合血都变少,总会杀死。else printf("Case #%lld: NO\n",++i);//否则杀不死。 } return 0;}
0 0
- BZOJ系列3856《Monster》题解
- BZOJ 3856 Monster 不公平博弈
- BZOJ 3856 Monster C++语言入门题
- BZOJ系列3907《网格》题解
- 3856: Monster
- Fight the Monster题解报告
- BZOJ系列2748《[HAOI2012]音量调节》题解
- BZOJ系列1491《[NOI2007]社交网络》题解
- BZOJ系列1090《[SCOI2003]字符串折叠》题解
- BZOJ系列1293《[SCOI2009]生日礼物》题解
- BZOJ系列1088《[SCOI2005]扫雷Mine》题解
- BZOJ系列3043《IncDec Sequence》题解
- BZOJ系列2005《[Noi2010]能量采集》题解
- BZOJ系列3721《PA2014 Final Bazarek》题解
- BZOJ系列1922《[Sdoi2010]大陆争霸》题解
- BZOJ系列1049《[HAOI2006]数字序列》题解
- BZOJ系列1406《[AHOI2007]密码箱》题解
- BZOJ系列1296《[SCOI2009]粉刷匠》题解
- Jetty和Tomcat的使用及性能测试
- Oracle CASE WHEN 用法介绍
- spark内核揭秘-09-RDD的count操作 触发Job全生命周期-02
- Kafka学习笔记
- jackson中自定义处理序列化和反序列化
- BZOJ系列3856《Monster》题解
- oracle(oracle的函数)
- C语言去除空格方法
- java线程系列
- 安卓 imageview资源图片ID获取方法
- SQLServer中的全局变量
- 在tomcat下部署工程方式
- hdoj1071积分求面积
- Android开发在string.xml文件中设置部分字体颜色大小