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,转载请注明来源
  • 相关阅读:
    【Codeforces Round#279 Div.2】B. Queue
    210
    回溯
    HuffmanTree && HuffmanCode
    (转)STL
    2013 ACM/ICPC 长沙现场赛 A题
    不是数据库中的列,而是查询结果集中的列
    又出现新问题,所以又发现了之前的一些问题 (关于修改表单地址,要不要改回来的问题) 原因已经解决
    MyEclipse导入jquery-1.8.0.min.js等文件报错的解决方案
    为什么突然 选择删除的按钮失效???
  • 原文地址:https://www.cnblogs.com/zhber/p/4257163.html
Copyright © 2011-2022 走看看