• nyoj 599-奋斗的小蜗牛 (double ceil(); (temp


    599-奋斗的小蜗牛


    内存限制:64MB 时间限制:1000ms 特判: No
    通过数:0 提交数:96 难度:1

    题目描述:

    传说中能站在金字塔顶的只有两种动物,一种是鹰,一种是蜗牛。一只小蜗牛听了这个传说后,大受鼓舞,立志要爬上金字塔。为了实现自己的梦想,蜗牛找到了老鹰,老鹰告诉它金字塔高H米,小蜗牛知道一个白天自己能向上爬10米,但由于晚上要休息,自己会下滑5米。它想知道自己在第几天能站在金字塔顶,它想让你帮他写个程序帮助它。

    输入描述:

    第一行有一个整数t,表示t组测试数据。
    第二行一个整数H(0<H<10^9)代表金字塔的高度。

    输出描述:

    输出一个整数n表示小蜗牛第n天站在金字塔顶上
    

    样例输入:

    2
    1
    5

    样例输出:

    1
    1

    C/C++  (新OJ格式错误,老OJ  AC):

    #include <iostream>
    #include <algorithm>
    #include <cstring>
    #include <cstdio>
    #include <cmath>
    #include <stack>
    #include <set>
    #include <map>
    #include <queue>
    #include <climits>
    #include <bitset>
    #define PI 3.1415926
    
    using namespace std;
    const int MY_MAX = 10005;
    int N, A[MY_MAX];
    
    int main()
    {
        cin >>N;
        while (N --)
        {
            double temp;
            scanf("%lf", &temp);
            if (temp >= 0 && temp <= 10)
                printf("1
    ");
            else
            {
                cout <<ceil((temp - 5) / 5) <<endl;
            }
        }
    
        return 0;
    }
  • 相关阅读:
    SQL里面的函数应用
    Split的小用法
    堆栈和堆问题
    break,continue,goto,Return几个方法
    接口笔记
    抽象类
    虚方法
    将博客搬至CSDN
    运行数据区
    美团-走迷宫
  • 原文地址:https://www.cnblogs.com/GetcharZp/p/9349084.html
Copyright © 2020-2023  润新知