您的位置:首页 > 其它

hdu 1302(简单模拟题)

2013-04-26 12:28 316 查看
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1302

思路:直接按着题目意思模拟就行了。。。

View Code

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
double h,u,d,f;
while(~scanf("%lf",&h)&&h){
scanf("%lf%lf%lf",&u,&d,&f);
int day=0;
bool flag=true;
double dist=0,s=u*f/100;
while(1){
day++;
dist+=u;
if(dist>h)break;
dist-=d;
if(dist<0){flag=false;break;};
u-=s;
if(u<0)u=0;
}
if(flag){
printf("success on day %d\n",day);
}else
printf("failure on day %d\n",day);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: