杭电acm1302

#include <stdio.h>

int main() {
	
	int i;//i应定义为int 
	double h, u, d, f, lost, temp, len;//这几个要定义为double 

	while(scanf("%lf%lf%lf%lf", &h, &u, &d, &f)!=EOF && h) {
		i = 1;
		len = 0;
		lost = u * f / 100;
		while(i) {
			temp = u - (i-1) * lost;
			len += temp;
//printf("%lf", temp);
			if(len>h) {			//需为大于号,大于等于号为 WrongAnswer 
				printf("success on day %d\n", i);
				break;
			}
			len -= d;
//printf("  %lf\n", len);
			if(temp<0 || len<0) {//都是小于号,小于等于为 WrongAnswer 
				printf("failure on day %d\n", i);
				break;
			}
			i ++;
		}	
	}
	
	return 0;
}

posted @ 2015-10-04 16:43  StevenLuke  阅读(130)  评论(0编辑  收藏  举报