题意:蜗牛在深为H的井底,白天爬U,晚上掉D,然后每天少爬初始 一天爬高度的10%,问几天爬出井或者到负高度
题解:一天天模拟就好→_→,
#include<bits/stdc++.h>
using namespace std;
double h,u,d,f;
void Gao()
{
int day=1;
double height=0.0;
f=u*1.0*f/100.0;
while (true)
{
height+=max(u,0.0);
//cout<<u<<" "<<day<<" "<<height<<endl;
if (height>h)
{
cout<<"success on day "<<day<<endl;
return;
}
u-=f;
height-=d;
if (height<0)
{
cout<<"failure on day "<<day<<endl;
return ;
}
day++;
}
}
int main()
{
//freopen("a.in","r",stdin);
while (cin>>h>>u>>d>>f && h!=0)
Gao();
return 0;
}