Bzoj 3856:monster "Miscellaneous questions"

Source: Internet
Author: User

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"

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.