【bzoj3856】Monster 乱搞

题目描述

你要打一只h点血的怪物,每回合你攻击会造成a点伤害,回合结束后怪物会回b点血,你每攻击k回合需要休息一次,该回合不能造成伤害。怪物血量降到0以下就会死亡,问最后能否打死怪物。

输入

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).

输出

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".

样例输入

5 3 2 2
0 0 0 0

样例输出

Case #1: NO


题解

乱搞

玩过游戏的人都知道,游戏获胜的方式大致分为三种:

一波流:一次攻击直接打死怪物;

压制流:一直造成伤害,在自己疲劳期之前打死怪物;

消耗流:在自己休息之后怪物的血量比以前少,可以一直消耗血量。

然后特判这三种情况即可。

#include <cstdio>
int main()
{
	int h , a , b , k , c = 0;
	while(scanf("%d%d%d%d" , &h , &a , &b , &k) && h)
		printf("Case #%d: %s\n" , ++c , a >= h || (long long)(k - 1) * (a - b) + a >= h || (long long)a * k > (long long)b * (k + 1) ? "YES" : "NO");
	return 0;
}

 

 

posted @ 2017-10-18 20:29  GXZlegend  阅读(337)  评论(0编辑  收藏  举报