hdu 1302 The Snail (模拟)

点击打开链接

简单模拟。。

#include<stdio.h>
#include<string.h>
int main(){      
	double h,u,d,f,height;
	int day;
	while(scanf("%lf%lf%lf%lf",&h,&u,&d,&f),h)
	{
		f=(f/100)*u;
		u=u+f;
		day=1;
		height=0;
		while(1){
			u-=f;
			if(u>0)
				height+=u;
			if(height>h){
				printf("success on day %d\n",day);
				break;
			}
			height-=d;
			if(height<0){
				printf("failure on day %d\n",day);
				break;
			}
			day++;
		}
	}
	return 0;
}


你可能感兴趣的:(hdu 1302 The Snail (模拟))