HDU-4950 monster

Source: Internet
Author: User


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 ;}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.