Virus Outbreak
InterviewTime limit2sMemory limit512 MB
Read hour values until -1 and print the Fibonacci number a(X) for each in the format 'Hour X: Y cow(s) affected'.
- Level
Easy3 of 10
- Topics
- Math, Dynamic programming, Implementation, Recursion
- Solved
- No attempts yet
Problem
The veterinary authority has reported an outbreak of a newly discovered cattle disease. Every affected cow has been euthanized to protect the industry. The cumulative numbers of affected cows after 8, 9, and 10 hours were 21, 34, and 55 respectively.
The counts follow the Fibonacci sequence. With , , and for every , write a program that computes the cumulative count for a given hour .
Input
The input consists of several lines. Each line contains one positive integer no greater than 490, representing an hour. The last line contains -1, which terminates the input and must not be processed.
Output
For each input value, print one line in the format Hour X: Y cow(s) affected, where X is the given hour and Y is the cumulative number of affected cows at that hour.