题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1302
#include <iostream> #include<cstdio> #include <cstring> #include<cmath> #define maxn 50000 using namespace std; int main() { int h,u,d,n; double f; while(scanf("%d",&h)&&h) { scanf("%d%d%lf",&u,&d,&f); int day=0; double ff=f/100; double sum=0; while(sum>=0&&sum<=h) { sum+=u-u*ff*day-d; day++; } if(sum<0) printf("failure on day %d\n",day); else if(sum>h) printf("success on day %d\n",day-1); //最后爬出去是白天,所以最后那一天不算 } return 0; }
HDU 1302 the snail 水一水
猜你喜欢
转载自blog.csdn.net/zvenWang/article/details/81947644
今日推荐
周排行