hdu_1049 Climbing Worm(数学,模拟)

来源:互联网 发布:mac邮件里面的qq邮箱 编辑:程序博客网 时间:2024/05/17 06:13

http://acm.hdu.edu.cn/showproblem.php?pid=1049

 

分析:

      小学数学题,直接用模拟做

 

代码:

#include<cstdio>#include<string>#include<cstring>#include<cmath>#include<iostream>#define LL long longusing namespace std;int n,u,d;int main(){   // freopen("in.txt","r",stdin);int ans,s;while(scanf("%d%d%d",&n,&u,&d)!=EOF){        if(!n) return 0;        ans=0;        for(int i=0;i<n;){            i+=u;            ans++;            if(i>=n) break;            i-=d;            ans++;        }        printf("%d\n",ans);}return 0;}


 

0 0
原创粉丝点击