#K8321. Egg Drop Problem with Two Eggs
Egg Drop Problem with Two Eggs
Egg Drop Problem with Two Eggs
You are given a building with n floors and two eggs. Your task is to determine the minimum number of attempts required in the worst-case scenario to find the highest floor from which an egg can be dropped without breaking.
The problem can be formulated as finding the smallest integer k such that the following inequality holds:
\(\frac{k\times (k+1)}{2} \ge n\)
For example, if n = 10, the answer is 4 because 1 + 2 + 3 + 4 = 10. Similarly, if n = 100, the answer is 14 because \(1+2+...+14=105\) which is the first summation greater or equal to 100.
Note: When n is 0, the number of attempts should be 0.
inputFormat
Input: A single integer n is provided via standard input, representing the number of floors in the building.
outputFormat
Output: Output a single integer representing the minimum number of attempts required to determine the critical floor in the worst-case scenario.
## sample10
4