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;
}