zoukankan      html  css  js  c++  java
  • bzoj3856 Monster

    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
    ");
            else if(k*a>(k+1)*b)printf("YES
    ");
            else printf("NO
    ");
        }
    }
    
    ——by zhber,转载请注明来源
  • 相关阅读:
    LeetCode 230. Kth Smallest Element in a BST
    LeetCode 114. Flatten Binary Tree to Linked List
    LeetCode 222. Count Complete Tree Nodes
    LeetCode 129. Sum Root to Leaf Numbers
    LeetCode 113. Path Sum II
    LeetCode 257. Binary Tree Paths
    Java Convert String & Int
    Java Annotations
    LeetCode 236. Lowest Common Ancestor of a Binary Tree
    LeetCode 235. Lowest Common Ancestor of a Binary Search Tree
  • 原文地址:https://www.cnblogs.com/zhber/p/4257163.html
Copyright © 2011-2022 走看看