Who Has Seen the Wind
InterviewTime limit2sMemory limit512 MB
Given humidity h and a time limit M, evaluate the quartic altitude formula hour by hour and report the first hour the balloon's altitude drops to zero or below.
- Level
Easy3 of 10
- Topics
- Math, Simulation, Brute force, Implementation
- Solved
- No attempts yet
Problem
Margaret has watched the wind drift over the prairies for a long time. From these observations she has built a formula that predicts the altitude of a weather balloon launched from her house. Specifically, the altitude (in metres above the ground) at hour after the launch is:
where is an integer humidity value between and inclusive.
Margaret wants to know the earliest hour (if any) at which the balloon will hit the ground after launch, as long as it is no later than the maximum time she is willing to wait. The balloon is considered to touch the ground when .
To find this, compute the altitude at , , until the balloon touches the ground or is reached.
Input
Two non-negative integers are given: , the humidity factor, followed by , the maximum number of hours Margaret will wait for the balloon to return to the ground. You may assume and .
Output
Print exactly one of the following on a single line:
The balloon does not touch ground in the given time.The balloon first touches ground at hour: T
where is the positive integer representing the earliest hour at which the altitude is less than or equal to zero.