码迷,mamicode.com
首页 > 其他好文 > 详细

URAL 1820. Ural Steaks(数学啊 )

时间:2015-03-16 19:22:37      阅读:105      评论:0      收藏:0      [点我收藏+]

标签:数学   ural   

题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1820


1820. Ural Steaks

Time limit: 0.5 second
Memory limit: 64 MB
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


PS:

选择尽快先炸掉每块牛排的其中一个面!

对于案例:
第一步:a1, b1;

第二步:c1, a2;

第三步:b2, c2;

代码如下:

#include <cstdio>
#include <cstring>

int main()
{
    int n, k;
    while(~scanf("%d%d",&n,&k))
    {
        if(n < k)
        {
            printf("2\n");
            continue;
        }
        int tt = (2*n)%k;
        int ans = 2*n/k;
        if(tt)
        {
            ans+=1;
        }
        printf("%d\n",ans);
    }
    return 0;
}


URAL 1820. Ural Steaks(数学啊 )

标签:数学   ural   

原文地址:http://blog.csdn.net/u012860063/article/details/44309733

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!