965A Paper Airplanes

A. Paper Airplanes
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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

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

Input

The only line contains four integers kknnsspp (1k,n,s,p1041≤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
Copy
5 3 2 3
output
Copy
4
input
Copy
5 3 100 1
output
Copy
5
Note

In the first sample they have to buy 44 packs of paper: there will be 1212 sheets in total, and giving 22 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.


题解:k个人折纸飞机,每个人必须折n个纸飞机,然后有一张纸能够折s个纸飞机,一包纸有p张纸。输出最少需要购买的纸的包数。一道简单题,看了很久,第二组样例是
的意思,5个人,每个人需要折3个纸飞机,一张纸能够折100个纸飞机,一包纸里面只有一张纸,虽然一张纸能够折100个飞机,但是每张纸只能一个人用,所以需要5包纸。


题解:模拟   先算出每个人需要的纸,然后乘以人数除以一包纸里的纸张数,就是包数。要向上取整。比如样例二,每个人需要折三个飞机,一张纸能折100个,3/100就是每个人需要纸张数,不向上取整就是0了。然后乘以人数,就是需要总的纸张数,除以每包纸的数,也要向上取整。c++有ceil函数,在math头文件里面,表示向上取整。最后的结果要强转为Int类型,不然第三组数据,结果有点问题,不用ceil,也可以取余判断,余0,就是除的结果,否则结果+1。

#include<bits/stdc++.h>
using namespace std;
int main()
{
    double k,n,s,p;
    cin>>k>>n>>s>>p;
    cout<<int(ceil(ceil(n/s)*k/p));
    return 0;
}


猜你喜欢

转载自blog.csdn.net/memory_qianxiao/article/details/80098556