(HDU) 1302-the Snail (snail)

Source: Internet
Author: User

Title Link: http://vjudge.net/problem/HDU-1302

Analysis: The limitations of this problem are many, one day is divided into day and night. It is not possible to use the rise-fall as a daily change (what if the day goes out?). )。

At the beginning of the initial position to set the double type of 0, I wrote the int type, depressed for half a day.

Be aware that the up distance cannot be negative, even if you are tired.

1#include <cstdio>2#include <cstring>3#include <cmath>4#include <iostream>5#include <algorithm>6#include <string>7#include <cstdlib>8 9 using namespacestd;Ten  One intMain () A { -     DoubleHeight,up,down,factor,delta; -      while(~SCANF ("%LF",&height)) the     { -         if(height==0) Break; -scanf"%lf%lf%lf",&up,&down,&factor); -         intday=0, flag=0; +         DoublePlace=0, first=Up ; -Delta= (first*factor*0.01); +          for(day=1;; day++) A         { at             if(up>=0) place+=Up ; -             if(place>height) -             { -flag=1; -                  Break; -             } inplace-=Down ; -             if(place<0) to             { +flag=0; -                  Break; the             } *             if(up>=0) up-=Delta; $         }Panax Notoginseng         if(flag) printf ("success on day%d\n", day); -         Elseprintf"failure on day%d\n", day); the     } +     return 0; A}

(HDU) 1302-the Snail (snail)

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.