Problem H
Touch The ISS
In the wake of the preparations behind uniting North America to raid Area $51$ to “see them aliens”, another strong front of individuals teamed up to accomplish a very different objective - to build a human pyramid to invade the International Space Station.
Now, everyone knows that the strategy that would use the fewest people is everyone standing one on top of another in a single (1-dimensional) tower of humans, but this isn’t realistic for obvious reasons. So instead they’re going to have to build some sort of pyramid. But a standard pyramid is also unrealistic because each level of the pyramid (starting from the top) needs more people immediately below it. So an online think tank decided to combine these two ideas, and instead has decided to build a human structure of multiple levels of pillars of humans.
In words, let’s assume that each pillar has $s$ people, all with average height $h$. Then, for sake of simplicity, we assume that each pillar has height exactly $H=s \cdot h$. The pillars that stand on the ground need no support. However, any pillar not on the ground needs to be supported by exactly $u$ other pillars of equal height. See the sample visualizations for further clarity.
Using the manpower you have at your disposal (the number of people who ticked “going” on the Facebook group - we’re going to call this number $p$), you must determine if it’s possible to reach the ISS, which is at a height $h$ from the base of the structure.
Yes, this is a math question.
Input
The first line of the input contains the integers $p$ and $a$ ($0 \leq p \leq 10^{10}$, $1 \leq a \leq 10^6$), the total manpower that has signed up to do this, and the altitude of the ISS in meters.
The second line contains the integers $h$, $s$ and $u$ ($1 \leq h \leq 10$, $1 \leq s \leq p$, $2 \leq u \leq 100$), the average height of a person participating in meters, the number of people per pillar, and the number of pillars needed to support each pillar.
Don’t try to hardcode this - while the ISS typically stays at around > $400$ km above sea level, the value of $a$ could vary as you need to test for other heights.
Output
If the total number of people needed to build this pyramid to the ISS is less than the number of people you have available, print that number. If the number of people needed is too great, print “no”.
Visualization of samples
| Sample Input 1 | Sample Output 1 |
|---|---|
6 8 2 2 2 |
6 |
| Sample Input 2 | Sample Output 2 |
|---|---|
5 8 2 2 2 |
no |
| Sample Input 3 | Sample Output 3 |
|---|---|
26 12 2 2 3 |
26 |
