It is a well-known fact that Rybinsk once used to be a great fishing spot. People who
lived in this town had fish for breakfast, lunch, and dinner. And whatever they could
not eat themselves, they shipped to other towns and cities. Therefore, optimizing the
fish cooking process was an important task.
Let us assume that today we caught N fish of the same size. Our frying pan fit up to
K fish. Another assumption is that each side of each fish has to be fried for one
minute. As a reminder, fish is usually fried on two sides.
And now let us count the minimum time we need to fry all the fish we have.
Limitations
1 ≤ N, K ≤ 500
Input
The input file contains two integer numbers N and K – the number of fish caught and
the number of fish that can fit into our frying pan.
Output
The output file must contain one integer number – the minimum time (minutes)
needed to fry all the fish.
Examples
Input.txt Output.txt
3 2 3
4 2 4
题意:渔民煎鱼,有n条鱼,有一个锅一次能煎k条鱼,一条鱼两面全煎,煎一面需要1分钟,问将全部鱼煎完最少需要多少时间
思路:
1.最少需要两分钟
2.思路就是每次肯定都将锅放满,所以直接按总面数算就可以了
ac代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
int x,y;
while(scanf("%d%d",&x,&y)!=-1)
{
if(2*x<=y)
printf("2\n");
else
{
if((2*x)%y==0)
printf("%d\n",(2*x)/y);
else
printf("%d\n",(2*x)/y+1);
}
}
return 0;
}