573-the Snail
Time limit:3.000 seconds
Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=99&page=show_problem &problem=514
A snail is at the bottom of a 6-foot, and wants to climb to the top. The snail can climb 3 feet while the sun are up, but slides down 1 foot in night while sleeping. The snail has a fatigue factor of 10%, which means that on each successive day the snail climbs 10% 3 = 0.3 feet Less than it did the previous day. (The distance lost to fatigue is always 10% of the ' the ' the ' s climbing distance.) On what day does the snail leave the "the", i.e ., what is the the "the", during which the snail ' s height exceed s 6 feet? (a day consists of a period of sunlight followed by a period of darkness.) As you can to the following table, the snail leaves the during the third day.
Your job is to solve this problem. Depending on the parameters of the problem, the snail would eventually either the leave of the "the" or slide back to the bottom of The. (In the other words, the snail's height would exceed the height of the "the" or become negative.) You are must find out which happens a. What day.
Input
The input file contains one or more test cases, and each on a line by itself. Each line contains four Integersh, U, D, and F, separated by a. If H = 0 It signals the end of the input; Otherwise, all four numbers would be between 1 and inclusive. H is the height of the "the" in feet, you are the distance in feet this snail can climb during the day, D is the distance In feet this snail slides down during the night, and F is the fatigue factor as a expressed. The snail never climbs a negative distance. If the fatigue factor drops the snail ' climbing distance to below zero, the snail does not climb. Regardless of how far the snail climbed, it always slides D feet at night.
Output
For each test case, output a line indicating whether the snail succeeded (left the) or failed (slid back to the Botto m) and on what day. Format the output exactly as shown in the example.