zhber
有好多做过的题没写下来,如果我还能记得就补吧

Description

Teacher 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 reduced by a. 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".

 

Input

There 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).

 

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
 
真的好那啥的一道题……
一个人打怪,怪有h滴血,每个回合人打怪造成a伤害,然后怪会回复b的血量。每k回合人要休息一次,然后怪还能继续回血。问人能不能打死怪
只要判断第k回合人能不能打死怪,判断人在k回合里造成的伤害是不是比怪在k+1回合里回的血多就好了
#include<cstdio>
#include<iostream>
using namespace std;
#define LL long long
LL h,a,b,k;
int tt;
int main()
{
    while(scanf("%lld%lld%lld%lld",&h,&a,&b,&k)&&h&&a&&b&&k)
    {
        tt++;printf("Case #%d: ",tt);
        if(h<=(a+max(0ll,(k-1)*(a-b))))printf("YES\n");
        else if(k*a>(k+1)*b)printf("YES\n");
        else printf("NO\n");
    }
}

 

posted on 2015-01-28 21:37  zhber  阅读(159)  评论(0编辑  收藏  举报