题目
In China, there is a very famous problem about pancakes: You have a pan and you can fry two pancakes at the same time each time. For a pancake, its front and back sides need to be cooked, and it takes one hour for each side to be cooked.
So how long does it take at least to cook 3 pancakes? The answer is three hours:
In the first hour, fry the front of No.1 pancake and the front of No.2 pancake.
In the second hour, fry the back of No.2 pancake and the front of No.3 pancake.
In the third hour, fry the back of No.1 pancake and the back of No.3 pancake.
Now you have a pan and you can fry KK pancakes at the same time each time. How many hours does it takes at least to cook NN pancakes?
It’s noticed that you have to fry some side of the pancake until fully cooked every time, it means that you can’t fry some side of the pancake half-cooked and taking it out. So the answers are always integers.


题意
一口锅可以同时煎制k个饼,每张饼两面都需要煎制,每一面需要煎1小时,问最快把n张饼全部煎好需要多少小时
思路
共有n张饼就意味着如果一张一张煎制的话总时间是2*n 但是现在可以同时煎制
如果

博客围绕煎饼问题展开,给出一口锅每次可同时煎制k个饼,每张饼两面各需煎1小时的条件,询问煎n张饼的最短时间。分析思路为考虑不同情况,若2*n能被k整除,答案是2*n/k;若不能整除,答案是2*n/k + 1,并给出了解题代码。
最低0.47元/天 解锁文章
231

被折叠的 条评论
为什么被折叠?



