CCC '11 J2 - Who Has Seen The Wind

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 256M

Problem type
Canadian Computing Competition: 2011 Stage 1, Junior #2

Margaret has looked at the wind floating over the prairies for a long time. After these observations, she has created a formula that will describe the altitude of a weather balloon launched from her house. In particular, her equation predicts the altitude A (in metres above the ground) at hour t after launching her balloon is:

A=6t4+ht3+2t2+t

where h is an integer value representing the humidity as a value between 0 and 100 inclusive.

Margaret is curious at what the earliest hour is (if any) that her weather balloon will hit the ground after launch, so long as it is no more than the maximum time, M, that Margaret is willing to wait. You can assume that the weather balloon touches ground when A0.

In order to do this, your program should use the formula to calculate the altitude when t=1, t=2, and so on, until the balloon touches the ground or t=M is reached.

Input Specification

The input is two non-negative integers: h, the humidity factor, followed by M, the maximum number of hours Margaret will wait for the weather balloon to return to ground. You can assume 0h100 and 0<M<240.

Output Specification

If the balloon does not touch the ground in the given time, then output

Copy
The balloon does not touch ground in the given time.

Otherwise, output

Copy
The balloon first touches ground at hour:
T

where T is a positive integer value representing the earliest hour when the balloon has altitude less than or equal to zero.

Sample Input 1

Copy
30
10

Output for Sample Input 1

Copy
The balloon first touches ground at hour:
6

Sample Input 2

Copy
70
10

Output for Sample Input 2

Copy
The balloon does not touch ground in the given time.

Comments


  • 0
    Crakxinator  commented 56 days ago

    This question may seem daunting, but it can be solved with a for loop and boollean variable. Good Luck!!!


  • 0
    studentcsaa7  commented 59 days ago

    this is so sigma


  • -1
    IsaZhou  commented on July 29, 2024, 12:15 p.m. edited

    If t gets bigger, shouldn't A get bigger as well?


    • -1
      TZ616  commented on Aug. 1, 2024, 5:38 p.m.

      The term with the highest power in this polynomial is 6t4, which has a negative coefficient. Therefore, A will eventually decrease and become negative if t is sufficiently large. The value of h does not affect this trend.


  • 5
    maxcruickshanks  commented on Jan. 1, 2024, 6:56 p.m.

    Since the original data were weak, three additional test cases were added, and all submissions were rejudged.