Zoj 1710Thesnail
Http://acm.zju.edu.cn/onlinejudge/showProblem.do? Problemid = 710
A snail bait crawls a little during the day and drops it by a given percentage. Shows the depth of the well, the number of meters per day, and the percentage of the slides. Ask if you can climb out or fall to the bottom of the well in a few days.
A small simulation, it should be noted that the end of the day is counted after the crawling and slipping. In addition, the depth must be greater than or less than 0.Is regarded as successful or failed, is not counted.
Details +Code:
# Include <stdio. h> # include <math. h> int main () {int I, j; double H, U, d, f, sum, F1; for (I = 1; I ++) {scanf ("% lf", & H, & U, & D, & F); If (H = 0) break; sum = 0; f1 = u * f * 1.0/100.0; For (j = 1; j ++) {If (J! = 1) U = u-f1; If (U <= 0) u = 0; sum = sum + U; If (sum> H) {printf ("success on day % d \ n", J); break;} sum = sum-D; If (sum <0) {printf ("Failure on day % d \ n", J); break ;}} return 0 ;}