The little snail NYOJ-599 struggle

Source: Internet
Author: User
Original title Link

NYOJ-599 struggling little snail description

Legend can stand at the top of the pyramid only two kinds of animals, one is an eagle, one is a snail. A little snail listened to this legend, greatly encouraged, determined to climb the pyramid. In order to realize their dream, the snail found the eagle, the eagle told it pyramid high h meters, the small snail know a day can climb up to 10 meters, but due to rest in the evening, they will fall 5 meters. It wants to know that he can stand at the top of the pyramid for the first few days, and it wants you to help him write a program to help it. Analysis

Pay attention to the last 10 meters when the snail arrived at once, will not fall down the Code

#include <stdio.h>
#include <iostream>
using namespace std;
int main ()
{
    int n;
    CIN >> N;
    while (n--)
    {
        int h;
        Cin >> H;
        if (h<=10)
        {
            cout << 1 << endl;
        }
        else{
            if (h%5==0)
            {
                cout << (h-10)/5 + 1<< Endl;
            }
            else
            {
                cout << h/5 << Endl
            }
    }} return 0;
}        

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.