573 - The Snail

来源:互联网 发布:合法的c语言标识符 编辑:程序博客网 时间:2024/06/06 02:42
#include <iostream>using namespace std;int main(){    double H,U,D,F,count,j;    int  i,flag;    while(cin>>H>>U>>D>>F)    {        if(H==0&&U==0&&D==0&&F==0)break;        else        {            count=0;            flag=0;            j=U/100*F;            for(i=0;; i++)            {                if(i>=1) U=U-j;                if(U<0)U=0;                count+=U;                if(count>H)                {                    flag=1;                    break;                }                count=count-D;                if(count<0)break;            }            if(flag==1)cout<<"success on day "<<i+1<<endl;            else cout<<"failure on day "<<i+1<<endl;        }    }    return 0;}

原创粉丝点击