uva 573 水题

来源:互联网 发布:淘宝客服子账号认证 编辑:程序博客网 时间:2024/05/16 09:31
#include <stdio.h>#include <iostream>#include <string.h>using namespace std ;#define eps 1e-8int main(){    //freopen("input.txt", "r", stdin) ;    int h, u, d, f ;    while(scanf("%d %d %d %d", &h, &u, &d, &f) && h){        double now = 0 ;        double t = 1.0 * u * f / 100.0 ;        double a = (double)(u) ;        int res = 1 ;        bool flag = 0 ;        for(res =1; ; res++){            if(a > 0) now = now + a ;            if(now > h){                flag = 1 ;  break ;            }            now = now - d ;            if(now < 0)   break ;            a = a - t ;        }        printf("%s on day %d\n", flag ? "success" : "failure", res) ;    }    return 0 ;}