题意:H代表墙的高度,U代表的白天要爬的高度,D代表晚上要下降的高度,F代表每天要减少的高度百分比。。。然后就是单纯的模拟了
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
double H,U,D,F;
while (scanf("%lf%lf%lf%lf",&H,&U,&D,&F) != EOF )
{
if ( H==0&&U==0&&D==0&&F==0 )
break;
double heigh=0;
double down=U*F/100.0;
int cur=1;
bool flag = false ;
while (1)
{
if ( U > 0)
heigh += U ;
if(heigh > H )
{
printf("success on day %d\n",cur);
break;
}
heigh -= D , U -=down;
if (heigh < 0)
{
printf("failure on day %d\n",cur);
break;
}
cur++;
}
}
return 0;
}