UVA 573 Solution

/*
  Name:  UVA573
  Author: zoom
  Date: 31/07/11
*/
using namespace std;
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<limits>
#include<cmath>
#include<queue>
#include<map>
#define LLU long long unsigned int
#define LLD long long double
#define FOR(i,N) for(int i=0;i<(N);i++)
int main()
{
    int H,U,D,F;
    while(cin>>H>>U>>D>>F and (H||D||U||F))
    {
        bool success=false;
        int day=1;
        double UF=U,Height=0.0F,FF=UF*F/100.0;
        while(true)
        {
            if(UF>0)
            Height+=UF;
            if(Height>H)
            {
                success=true;
                break;
            }
            Height-=D;
            if(Height<0) break;
            UF-=FF;
//            cout<<“day=”<<day<<” “<<Height<<” “<<UF<<” “<<D<<“\n”;
            day++;
        }
        if(success) cout<<“success on day “<<day<<endl;
        else cout<<“failure on day “<<day<<endl;
    }
}

Leave a comment