Paper Airplanes - CodeForces965A

我简直是有毒。。。本来这也就是个十几分钟就干掉的sb题我硬生生花了一整个小时。。。。


To make a paper airplane, one has to use a rectangular piece of paper. From a sheet of standard size you can make s airplanes.

A group of k people decided to make n airplanes each. They are going to buy several packs of paper, each of them containing p sheets, and then distribute the sheets between the people. Each person should have enough sheets to make n airplanes. How many packs should they buy?

Input

The only line contains four integers k, n, s, p (1≤k,n,s,p≤104) — the number of people, the number of airplanes each should make, the number of airplanes that can be made using one sheet and the number of sheets in one pack, respectively.

Output

Print a single integer — the minimum number of packs they should buy.

Examples

Input
5 3 2 3
Output
4

Input
5 3 100 1
Output
5

Note

In the first sample they have to buy 4 packs of paper: there will be 12 sheets in total, and giving 2 sheets to each person is enough to suit everyone’s needs.

In the second sample they have to buy a pack for each person as they can’t share sheets.

大意:一张纸能做s个飞机,有k个人每个人都做n个飞机,一包纸有p张,他们之间可以分纸,问最少要买几包。

我大概是当时脑子不在状态(大概是还没从闪4实况里掉出来。。)

其实很简单,这样想,我们知道了一个人要叠n架纸飞机,一张纸能叠s架纸飞机,那这一个人叠n架纸飞机要用掉几张纸?

知道了一个人需要多少纸,那么k个人需要多少纸就明确了。然后去根据总纸数去确定包数,而不要试图用包数确定纸数,那样是不好想的。

要注意,当n不大于s时,只需要一张纸就能满足一个人的需求。所以不能简简单单的用n/s来判断一个人要多少纸。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 2333
using namespace std;
int k, n, s, p;
int main() {
cin >> k >> n >> s >> p;
int sum;
if (n == s || n < s)
sum = k;
else if (n % s == 0)
sum = k * (n / s);
else
sum = k * (n / s + 1);
if (sum % p == 0)
cout << sum / p << endl;
else
cout << sum / p + 1 << endl;
//system("pause");
return 0;
}

-------------本文结束,感谢您的阅读转载请注明原作者及出处-------------


本文标题:Paper Airplanes - CodeForces965A

文章作者:Shawn Zhou

发布时间:2018年12月14日 - 20:12

最后更新:2019年01月18日 - 19:01

原始链接:http://shawnzhou.xyz/2018/12/14/18-12-14-01/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。

知识无价,码字不易。对您有用,敬请打赏。金额随意,感谢关心。
0%