Timus 1820. Ural Steaks 题解
2014-04-22 07:58
323 查看
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.
The only input line contains the integers n and k separated with a space (1 ≤ n, k ≤ 1000).
Output the minimal number of minutes in which the chef can cook n steaks.
看起来很简单的题目,但是却会让不少人栽跟斗。
主要考审题能力,理解能力,IQ。再次教训我读题要仔细,理解透切才好解题。
考点: 牛排是不能同时煎两面的
所以,如果写3*2/2 = 3这样的公式就肯定错了。
思路:先处理一面牛排,然后处理没有煎的牛排的一面和处理过的牛排的另一面,然后再翻没翻面的牛排,最后再得出结果。
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 ≤ n, k ≤ 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; } }
相关文章推荐
- Timus 1820. Ural Steaks
- Timus Online Judge:1820. Ural Steaks
- ural 1820. Ural Steaks 贪心
- URAL1820 - Ural Steaks - 贪心
- URAL 1820 Ural Steaks (贪心)
- ural 1820. Ural Steaks -思维题
- URAL 1820. Ural Steaks
- URAL 1820. Ural Steaks(数学啊 )
- Timus 1820
- URAL - 1820 Ural Steaks(小学生题)
- URAL 1820. Ural Steaks(数学啊 )
- Timus 1015. Test the Difference!
- Timus 1057. Amount of degrees
- Timus 1037. Memory management
- Timus 1800
- Timus 1727. Znaika's Magic Numbers
- Timus 1658
- Timus 1078 最长路Floyd
- Ural(Timus) 1003 Parity
- Timus 1017. The Staircases(转)