1302 the snail.cpp
来自「威士忌的HDU题解.大概有260多题的源码。对于学习非常有好处。」· C++ 代码 · 共 32 行
CPP
32 行
#include <cstdio>
using namespace std;
int h,u,d,f;
double now,up,rate;
int main()
{
int day;
while( scanf("%d %d %d %d",&h,&u,&d,&f)!=EOF && h)
{
now=0;up=u;rate=(double)f/100 * u;
for(day=1; 1 ; day++)
{
now+= up;
if(now>h)
break;
now-= d;
if(now<0)
break;
up-=rate;
if(up<0)//注意up不为负
up=0;
}
if(now>=h)
printf("success on day %d\n",day);
else
printf("failure on day %d\n",day);
}
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?