Timus 1820. Ural Steaks 题解

After the personal contest, happy but hungry programmers dropped into the restaurant “Ural Steaks” and ordered  n specialty 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 most  k steaks can be cooked simultaneously. Find the time the chef needs to cook the steaks.

Input

The only input line contains the integers  n and  k separated with a space (1 ≤  nk ≤ 1000).

Output

Output the minimal number of minutes in which the chef can cook  n steaks.

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;
	}
}


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值