2009-01-17 22:42:08來源不明
ACM 573 The Snail
題目要看清楚啊,不然會眼花花找不到錯誤!
/*************************************************************/
- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- #include<math.h>
- main()
- {
- int flag,day;
- double f1,f,u,h,d,temp;
- while(scanf("%lf %lf %lf %lf",&h,&u,&d,&f)==4&&h!=0)
- {
- flag=0;temp=0;f1=u*f/100;day=0;
- while(flag==0)
- {
- day++;
- if(u<0) u=0;
- temp=temp+u;
- if(temp>h) {flag=1;break;}
- temp=temp-d;
- if(temp<0) {flag=-1;break;}
- u=u-f1;
- }
- if(flag==1) printf("success on day %d\n",day);
- else printf("failure on day %d\n",day);
- }
- return 0;
- }