Problem descriptionteacher 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 blocked by. 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 ".
Inputthere 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 ).
Outputfor 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 20 0 0 0
Sample output
Case #1: No
Question: give you the blood of monsters, your attack damage, and the blood of monsters in each cycle. You can choose to rest in any round, but you must rest in the continuous K rounds.
Idea: first, it must be the best if you don't have a rest. First, determine whether the first round will be killed directly, and then determine whether the first round will be dead if it does not return blood after the K round is completed, in addition, will the continuous k + 1 round cause damage to the monster?
# Include <iostream> # include <cstdio> # include <cstring> # include <algorithm> typedef long ll; using namespace STD; ll H, A, B, K; int main () {int CAS = 1; while (scanf ("% LLD", & H, & A, & B, & K )! = EOF & H + A + B + k) {printf ("case # % d:", CAS ++); If (H <=) {puts ("yes"); continue;} If (H-K * A + (k-1) * B <= 0 | (k + 1) * B-K * A) <0) puts ("yes"); else puts ("no");} return 0 ;}