UVa 573 the Snail (analog)

Source: Internet
Author: User
Tags time limit

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.