结果填空:青蛙爬井

有一口深度为 highhigh 米的水井,井底有一只青蛙,它每天白天能够沿井壁向上爬 upup 米,夜里则顺井壁向下滑 downdown 米。

若青蛙从某个早晨开始向外爬,当 high = 60405high=60405,up = 105up=105,dow = 35dow=35,计算青蛙多少天能够爬出井口?

注意:不能简单地认为每天上升的高度等于白天向上爬的距离减去夜间下滑的距离,因为若白天能爬出井口,则不必等到晚上。

样例输入复制
样例输出复制


模拟
 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4 #include <string>
 5 #include <algorithm>
 6 #include <cmath>
 7 #include <queue> 
 8 using namespace std;
 9 int a[10];
10 
11 int main()
12 {
13     int a,b,c;
14     cin>>a>>b>>c;
15     int t=0;
16     while(a){
17         t++;
18         a-=b;
19         if(a<0) break;
20         a+=c;
21     }
22     cout<<t<<endl;
23     return 0;
24 }

 

转载于:https://www.cnblogs.com/shixinzei/p/10559288.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值