Timus 1820. Ural Steaks 题解

本文介绍了一道关于计算烹饪牛排所需最短时间的问题。通过分析题目要求,给出了详细的解题思路及C++代码实现,重点在于理解每面牛排需要独立烹饪的特点。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

After the personal contest, happy but hungry programmers dropped into the restaurant “Ural Steaks” and orderednspecialty steaks. Each steak is cooked by frying each of its sides on a frying pan for one minute.
Unfortunately, the chef has only one frying pan, on which at mostksteaks can be cooked simultaneously. Find the time the chef needs to cook the steaks.

Input

The only input line contains the integersnandkseparated with a space (1 ≤n,k≤ 1000).

Output

Output the minimal number of minutes in which the chef can cooknsteaks.

Sample

input output
3 2
3


看起来很简单的题目,但是却会让不少人栽跟斗。

主要考审题能力,理解能力,IQ。再次教训我读题要仔细,理解透切才好解题。

考点: 牛排是不能同时煎两面的

所以,如果写3*2/2 = 3这样的公式就肯定错了。

思路:先处理一面牛排,然后处理没有煎的牛排的一面和处理过的牛排的另一面,然后再翻没翻面的牛排,最后再得出结果。

#include <iostream>
using namespace std;

void UralSteaks()
{
	int a = 0, b = 0, t = 0;
	cin>>a>>b;
	if (a <= b) cout<<2<<endl;
	else 
	{
		t = a / b;//第一面
		int left = a % b;//剩下一面都没处理的
		a = t * b +  left;//优先处理没处理过的

		t += a / b;
		a =  a % b + left;//反转left
		t += a / b;
		if ( a % b ) t++;
		cout<<t<<endl;
	}
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值