列表

详情


NC216188. CookPancakes!

描述

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 pancakes at the same time each time. How many hours does it takes at least to cook 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.


输入描述

The first line has two integers .


输出描述

Output the answer.

示例1

输入:

3 2

输出:

3

原站题解

上次编辑到这里,代码来自缓存 点击恢复默认模板

pypy3(pypy3.6.1) 解法, 执行用时: 34ms, 内存消耗: 18800K, 提交时间: 2020-12-27 16:22:55

n,k=input().split()
n=int(n)
n*=2
k=int(k)
print(max((n//k+(n%k!=0)),2))

Python3(3.9) 解法, 执行用时: 35ms, 内存消耗: 2816K, 提交时间: 2021-05-13 20:12:21

a,b=map(int,input().split())
print(max((2*a+b-1)//b,2))

上一题