zoukankan      html  css  js  c++  java
  • 结果填空:青蛙爬井

    有一口深度为 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 }
  • 相关阅读:
    Dapper 基础用法
    测试的分类
    Python
    MySQL数据库的增删改查
    Python面向对象之
    Python面向对象之
    Python
    HTML5/CSS3/JS笔记
    Python-Flask框架之
    Python进程与线程
  • 原文地址:https://www.cnblogs.com/shixinzei/p/10559288.html
Copyright © 2011-2022 走看看