【 CodeForces - 799A 】Carrot Cakes(模拟,细节,有坑)
題干:
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?n,?t,?k,?d?(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 5Output
YESInput
8 6 4 6Output
NOInput
10 3 11 4Output
NOInput
4 2 1 4Output
YESNote
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?6?minutes the first oven bakes?4cakes, 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.
?
題目大意:
烤k個餅干需要t秒,她們要至少烤制n塊餅干。第一個爐子已經預熱好了,但是第二個爐子沒有。第二個爐子預熱需要d秒。k個餅干在t秒同時烤好,第二個爐子在預熱的時候只能用第一個爐子,第二個爐子預熱結束之后,兩個爐子可以同時用。請你幫幫她判斷應不應該用第二個爐子,在速度一樣快的時候她們嫌麻煩不去預熱第二個爐子(If the time needed with the second oven is the same as with one oven, then it is unreasonable.如果預熱第二個爐子總共花的時間和不預熱一樣,則認為不預熱第二個爐子),她們會選擇最快的一種方案。
解題報告:
? 先計算出一共要弄多少鍋(假設需要all鍋),然后看看all-1鍋的時間是否大于預熱的時間,如果嚴格大于預熱的時間我就可以在第一鍋弄著的時候,開一個第二鍋,時間一定短,輸出YES 否則就是NO。有個細節就是,這里需要嚴格大于!因為等于的意思是,我all-1鍋都好了(也就是,只差一鍋了),所以我開第二鍋和不開第二鍋都一樣的總時長了,所以依據題意,此時輸出NO。
AC代碼:
#include <bits/stdc++.h> using namespace std; int n,t,k,d; int main() {cin>>n>>t>>k>>d;if (k>=n) return 0*puts("NO");//神操作。 int guo=(n%k==0)?n/k:n/k+1;if ((guo-1)*t>d) return 0*puts("YES");return 0*puts("NO"); }?
總結
以上是生活随笔為你收集整理的【 CodeForces - 799A 】Carrot Cakes(模拟,细节,有坑)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mwd.exe - mwd是什么进程 有
- 下一篇: mxoaldr.exe - mxoald