• CF-799A


    A. Carrot Cakes
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    In some game by Playrix it takes t minutes for an oven to bake k carrot cakes, all cakes are ready at the same moment t minutes after they started baking. Arkady needs at least n cakes to complete a task, but he currently don't have any. However, he has infinitely many ingredients and one oven. Moreover, Arkady can build one more similar oven to make the process faster, it would take d minutes to build the oven. While the new oven is being built, only old one can bake cakes, after the new oven is built, both ovens bake simultaneously. Arkady can't build more than one oven.

    Determine if it is reasonable to build the second oven, i.e. will it decrease the minimum time needed to get n cakes or not. If the time needed with the second oven is the same as with one oven, then it is unreasonable.

    Input

    The only line contains four integers ntkd (1 ≤ n, t, k, d ≤ 1 000) — the number of cakes needed, the time needed for one oven to bake k cakes, the number of cakes baked at the same time, the time needed to build the second oven.

    Output

    If it is reasonable to build the second oven, print "YES". Otherwise print "NO".

    Examples
    input
    8 6 4 5
    output
    YES
    input
    8 6 4 6
    output
    NO
    input
    10 3 11 4
    output
    NO
    input
    4 2 1 4
    output
    YES
    Note

    In the first example it is possible to get 8 cakes in 12 minutes using one oven. The second oven can be built in 5 minutes, so after 6minutes the first oven bakes 4 cakes, the second oven bakes 4 more ovens after 11 minutes. Thus, it is reasonable to build the second oven.

    In the second example it doesn't matter whether we build the second oven or not, thus it takes 12 minutes to bake 8 cakes in both cases. Thus, it is unreasonable to build the second oven.

    In the third example the first oven bakes 11 cakes in 3 minutes, that is more than needed 10. It is unreasonable to build the second oven, because its building takes more time that baking the needed number of cakes using the only oven.

    题意:

    总共要烤n个蛋糕,开始有一个烤炉,每个烤炉可以在t分钟内出k个蛋糕,而再做一个烤炉要花费d分钟,问是否需要再做一个烤炉使总时间减少。

    首先我们要算出一个烤炉需要几个t才能完成,然后总时间减掉d算出这段时间第二个烤炉的工作量再加上一直在工作的第一个烤炉的量,若比之前多则为YES。

    注意样例2的情况

    附AC代码:

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 
     4 int main(){
     5     int n,t,k,d;
     6     cin>>n>>t>>k>>d;
     7     int x,y,z;
     8     if(n%k)
     9     n+=k-n%k;
    10     x=n/k;
    11     y=x*t-1;//t==d且x==2时为NO 
    12     z=(y-d)/t+y/t;
    13     if(z>=x)
    14     cout<<"YES"<<endl;
    15     else
    16     cout<<"NO"<<endl;
    17     return 0;
    18 } 
  • 相关阅读:
    [hdu6271]Master of Connected Component
    [hdu5468]Puzzled Elena
    [hdu4582]DFS spanning tree
    [poj2054]Color a Tree
    [luogu4107]兔子和樱花
    整除的尾数[HDU2099]
    胜利大逃亡[HDU1253]
    Bitset[HDU2051]
    折线分割平面[HDU2050]
    不容易系列之(4)——考新郎[HDU2049]
  • 原文地址:https://www.cnblogs.com/Kiven5197/p/6847138.html
Copyright © 2020-2023  润新知