Zoj 1710 the snail Il

Source: Internet
Author: User

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 ;}

 

 

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.