The Snail
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 1471 Accepted Submission (s): 1076
Problem Description a snail is at the bottom of a 6-foot well and wants to climb to the top. The snail can climb 3 feet while the sun was up and slides down 1 foot in night while sleeping. The snail has a fatigue factor of 10%, which means this on each successive day the snail climbs 10% * 3 = 0.3 feet less th An it does the previous day. (The distance lost to fatigue are always 10% of the first day ' s climbing distance.) On which day does the snail leave the well, i.e., what's the first day during which the snail ' s height exceeds 6 feet? (a day consists of a period of sunlight followed by a period of darkness.) As can see from the following table, the snail leaves the well during the third day.
Day Initial height Distance climbed height after climbing height after Sliding
1 0 3) 3 2
2 2 2.7) 4.7 3.7
3 3.7 2.4 6.1-
Your job is to solve this problem in general. Depending on the parameters of the problem, the snail would eventually either leave the well or slide back to the bottom of The well. (In other words, the snail ' s height would exceed the height of the well or become negative.) You must find off which happens first and on what day.
Input the input file contains one or more test cases with each of the line by itself. Each line contains four integers H, U, D, and F, separated to a single space. If H = 0 It signals the end of the input; Otherwise, all four numbers'll be between 1 and inclusive. H is the height of the feet, you are the distance in feet, the snail can climb during the day, and D is the distance In feet so the snail slides down during the night, and F are the fatigue factor expressed as a percentage. The snail never climbs a negative distance. If the fatigue factor drops the snail ' s climbing distance below zero, the snail does not climb at all,. Regardless of 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 well) or failed (slid back to th e bottom) and on the What day. Format the output exactly as shown in the example.
Sample Input
6 3 1 10 10 2 1 50 50 5 3 14 50 6 4 1 50 6 3 1 1 1 1 1 0 0 0 0
Sample Output
Success on day 3 failure in day 4 failure on day 7 failure on day success on day failure on Day 2 topic: a snail climbs up from the bottom of the hole and gives A strong number, respectively, indicates the depth of the well H can climb during the day, the distance of the night, and the number of consecutive days of climbing up the distance than the first day of loss of the percentage. Ask whether the snail can climb out of the well, or fall to the bottom of the idea: according to test instructions write the process on the line 2014.11,1 Alas, the title of the day after the climb, the less distance is compared with the first day, not the previous one, the day, thought that this sentence, is half a year to find problems. Read the question, although it is an English question.
#include <stdio.h>
int main () {
int h,i;
Double x,y,sum,a,b,c;
while (scanf ("%d", &h), h) {
scanf ("%lf%lf%lf", &a,&b,&c);
sum=0;y=a* (c/100);//The beginning of this writing is y=c/100; for
(i=0;; i++) {
sum=sum+a-b;
if (sum>=h) {
printf ("Success on Day%d\n", i);
break;
}
else if (sum<0) {
printf ("Failure on Day%d\n", i+1);
break;
}
a=a-y; This is written by A=a-a*y; a half-day error
}
}
return 0;