1.22 A

A - 1

Time limit 1000 ms
Memory limit 262144 kB

Problem Description

An elephant decided to visit his friend. It turned out that the elephant’s house is located at point 0 and his friend’s house is located at point x(x > 0) of the coordinate line. In one step the elephant can move 1, 2, 3, 4 or 5 positions forward. Determine, what is the minimum number of steps he need to make in order to get to his friend’s house.

Input

The first line of the input contains an integer x (1 ≤ x ≤ 1 000 000) — The coordinate of the friend’s house.

Output

Print the minimum number of steps that elephant needs to make to get from point 0 to point x.

Sample Input

5

12

Sample Output

1

3

问题链接:A - 1

问题简述:

输入n,问多少步可以到达n,一步可以走1,2,3,4,5步

问题分析:

每次都走5步,不足5步再加一步,问题变成n/5,如果n是5的倍数就直接输出n/5,若有余数再加一

程序说明:

没啥好说的。。。

AC通过的C语言程序如下:

#include <iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	if (n % 5 != 0)
	{
		cout << n / 5 + 1;
	}
	else { cout<<n / 5; }
}

猜你喜欢

转载自blog.csdn.net/weixin_44003969/article/details/86593529