A. Carrot Cakes
time limit per test  

1 second

memory limit per test  

256 megabytes

 

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".

 
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.

题目大意:

     有一个面包机每t分钟可以完成一次任务,每次任务可以制作k个蛋糕。

     现在有n个蛋糕需要被制作,为了提高效率他可以在花费d分钟再制作一个面包机

     在制作新机器的同时,旧机器依旧可以运作。新机器制作完成之后两台机器可以同时运转

     他最多可以制作一台新面包机。

     问重新制作一台面包机能否提高效率? 可以 YES 、 否NO

解题思路:

     大致思路就是分别计算出制作一台新机器完成任务所花费的总时间和只使用旧机器完成任务的总时间,然后比较。

     因为在制作新机器的同时,旧机器依旧可以运转,因为不好判断到底是新机器完成最后一次任务

     还是旧机器完成最后一次任务。所以分两种情况计算,找出最优情况(即花费时间最少的)

AC代码:

 #include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#define ll long long using namespace std; int main ()
{
int n,t,k,d;
int i,a,j;
while (scanf("%d %d %d %d",&n,&t,&k,&d)!=EOF)
{
if (k >= n){ // 新机器建造完成之前 蛋糕就能全部完成
printf("NO\n"); continue;
}
int len = (n+k-)/k;
i = d/t; // 建造新机器的过程中旧机器完成了几次任务(包括正在完成的)
if (i == ) i == ; // 正在完成的
if (d%t) i ++; j = len - i; // 还剩余几次任务
a = min(max(i*t+t*(j/),d+t*(j-j/)),max(i*t+t*(j-j/),d+t*(j*))); // 有可能是新机器最后完成 也有可能是旧机器最后完成 if (a >= len*t)
printf("NO\n");
else
printf("YES\n");
}
return ;
}

思路比较麻烦,仅供参考哈!

最新文章

  1. SYMBDSNAP_SDK[3943]: Failed to open device: /dev/symbdsnapctl, errno: 2
  2. [USACO] 铺放矩形块 题解
  3. Apache+PHP+MySQL
  4. Cgroups控制cpu,内存,io示例
  5. 学习笔记——Maven实战(九)打包的技巧
  6. Ext.Net 布局
  7. 【弱省胡策】Round #5 Handle 解题报告
  8. VisualStudio2013Preview对C++11的支持(转载)
  9. 【CKEditor ASP.NET】解决360安全浏览器极速模式下不显示
  10. Android 开发UI牛博[转]
  11. C#序列化总结
  12. QTableWidget class
  13. Quartz与Spring Boot集成使用
  14. The All-purpose Zero (最长公共子序列)
  15. XE 画矩形实现拖拉改变大小(属性)
  16. 重建二叉树POJ2255
  17. mysql innodb_buffer_pool_size mysql占用内存大小和主从复制并行线程数量
  18. MySQL Windows 安装与配置
  19. 登录时显示403 Access Denied
  20. js 背景自动切换

热门文章

  1. PHP会话cookie类的封装
  2. iptables开放所有端口
  3. [BZOJ 5158][Tjoi2014]Alice and Bob
  4. 1. JavaScript学习笔记——JS基础
  5. flutter 导入 http 库 import &#39;package:http/http.dart&#39; as http;
  6. 人机交互print
  7. 《Paxos Made Simple》翻译(转)
  8. Vue生命周期钩子详解【个人解读】
  9. 赋值运算与深浅copy
  10. selenium 之Ran 0 tests in 0.000s