2018年1月13日 星期六

UVA Q573 - The Snail

#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
long double a,b,c,d,e,f,g;
while(cin>>a>>b>>c>>d){
    if(a==0){
        break;
    }
    g=0;
    f=0;
    e=b*(d/100);
    while(1){
        f++;
        if(b>0){
            g=g+b;
        }
        if(g>a){
            cout<<"success on day "<<f<<endl;
            break;
        }
        g=g-c;
        if(g<0){
            cout<<"failure on day "<<f<<endl;
            break;
        }
        b=b-e;
    }
}


system("pause");
return 0;
}

沒有留言:

張貼留言