Hdu4950 Monster, hdu4950monster

Source: Internet
Author: User
Tags rounds

Hdu4950 Monster, hdu4950monster
MonsterTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission (s): 1782 Accepted Submission (s): 550


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

Authorxudyh
You know your attack power a, monster blood volume h, monster blood volume B in each round, and you must take a break in every k rounds. You can also take a rest in less than k rounds. Analysis: you only need to determine if the amount of blood that a monster drops per k rounds is greater than the returned amount of blood. Otherwise, NO.
# Include <iostream> # include <cstdio> # include <cstring> # include <stack> # include <queue> # include <map> # include <set> # include <vector> # include <cmath> # include <algorithm> using namespace std; const double eps = 1e-6; const double pi = acos (-1.0); const int INF = 0x3f3f3f3f; const int MOD = 1000000007; # define ll long # define CL () memset (a, 0, sizeof (a) int main () {ll h, a, B, k, cas = 1; while (~ Scanf ("% I64d % I64d % I64d % I64d", & h, & a, & B, & k), h + a + B + k) {if (a> = h | (a-B) * k-B> 0 | (a-B) * (k-1) + a> = h) // you only need to determine the number of rows of printf ("Case # % lld: YES \ n", cas ++) for each k-round monster's blood loss ratio ); else printf ("Case # % lld: NO \ n", cas ++);} return 0 ;}


Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.