Description
Teacher Mai has a kingdom. A Monster have invaded this kingdom, and Teacher Mai wants to kill it.
Monster initially has H HP. And it would die if HP was less than 1.
Teacher Mai and Monster take turns to do their action. In one round, Teacher Mai can attack the monster so, the HP of the monster would be reduced by a. At the end of this round, the HP of Monster is 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 is 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
The main topic: Every teacher of wheat to play monster punch, so that the monster hp reduce a drop of blood, monster reply B drop of blood, teacher every k to rest, ask can kill monster?
idea: water problem, the only thing to pay attention to is a hit will kill the situation and long long
#include <cstdio>
#define MAXN 100009
using namespace Std;
int main ()
{
Long Long h,a,b,k;
int cas=0;
while (1)
{
scanf ("%lld%lld%lld%lld", &h,&a,&b,&k);
if (! ( H|A|B|K)) break;
printf ("Case #%d:", ++cas);
if (long Long) (A-B) *k+b<0) {printf ("yes\n"); continue;}
if (Long Long) H (a) *k<=0) {printf ("yes\n"); continue;}
if (a>=h) {printf ("yes\n"); continue;}
printf ("no\n");
}
return 0;
}
Bzoj 3856:monster "Miscellaneous questions"