UVA 573

#include<iostream>
using namespace std;
int main()
{
    int  H,U,D,F;
    while(cin>>H>>U>>D>>F)
    {
        if(H==0)break;
        int i;
        double temp=double(U)*(F/100.0);
        double sum=U;
        for(i=1;;i++)
        {
            if(sum>H)
            {
                cout<<"success on day "<<i<<endl;
                break;
            }
            else
            {
                sum=sum-D;
                if(sum<0)
                {
                    cout<<"failure on day "<<i<<endl;
                    break;
                }
            }
                if(temp<0)
                {
                    cout<<"failure on day "<<i+1<<endl;
                    break;
                }
                else
                sum=sum+U-temp*i;
        }
    }
    return 0;

 

posted @ 2012-04-28 12:09  open your eyes  阅读(152)  评论(0编辑  收藏  举报