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?
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.
Print a single integer — the minimum number of packs they should buy.
5 3 2 3
4
5 3 100 1
5
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.
Problem solution: k people origami planes, each person must fold n paper planes, and then there is a sheet of paper that can fold s paper planes, and a pack of paper has p sheets of paper. Output the minimum number of packs of paper to be purchased. A simple question, I have read it for a long time, the second group of examples is
what it means, 5 people, each person needs to fold 3 paper planes, a piece of paper can fold 100 paper planes, there is only one piece of paper in a pack of paper, although one A sheet of paper can fold 100 planes, but each sheet of paper can only be used by one person, so 5 packs of paper are needed.
Solution: Simulation First calculate the amount of paper each person needs, and then multiply by the number of people divided by the number of papers in a pack, which is the number of packs. To be rounded up. For example, in Example 2, each person needs to fold three planes, and a piece of paper can fold 100 pieces. 3/100 is the number of sheets each person needs, and it is 0 if it is not rounded up. Then multiply by the number of people, that is, the total number of sheets needed, divide by the number of sheets per pack, and round up. C++ has the ceil function, which in the math header file means rounding up. The final result must be converted to Int type, otherwise the third group of data, the result is a bit problematic, you can also take the remainder judgment without ceil, the remainder 0 is the result of the division, otherwise the result is +1.
#include<bits/stdc++.h> using namespace std; intmain() { double k,n,s,p; cin>>k>>n>>s>>p; cout << int (ceil (ceil (n / s) * k / p)); return 0; }