ural 1820. Ural Steaks -思维题

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 ≤ n, k ≤ 1000).

Output

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

Sample

input output
3 2
3
Problem Author: Magaz Asanov
Problem Source: XII USU Open Personal Contest (March 19, 2011)

Tags: none  (

hide tags for unsolved problems )


题目大意

n个牛排,一锅只能煎k个牛排,一个牛排要煎两面,问最少几分钟煎完


解题思路

直接以面为单位,先求出每一锅都煎k个牛排,需要煎几锅,如果煎完这几锅之后还剩下面没煎,面的个数一定是小于k的,再煎一锅就够了


代码:

#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;

const int INF = 0x3f3f3f3f;



int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    if(n<=k) printf("2");
    else{
        ///直接以面为单位
        int ans = n*2/k;///每一锅都煎k个牛排,需要煎几锅
        if((n*2)%k) ans++;///如果煎ans锅之后还剩下面没煎,因为是取余,所以剩下的面数一定小于k,一锅就够了
        printf("%d",ans);
    }
    return 0;
}

你可能感兴趣的:(思维题)