-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathElephant.cpp
43 lines (36 loc) · 1.22 KB
/
Elephant.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* 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. */
#include <iostream>
using namespace std;
int main()
{
int elMove;
int out;
cin >> elMove;
while(elMove > 0){
if(elMove - 5 >= 0){
elMove = elMove - 5;
out = out + 1;
}else if(elMove - 4 >= 0){
elMove = elMove - 4;
out = out + 1;
}else if(elMove - 3 >= 0){
elMove = elMove - 3;
out = out + 1;
}else if(elMove - 2 >= 0){
elMove = elMove - 2;
out = out + 1;
}else if(elMove - 1 >= 0){
elMove = elMove - 1;
out = out + 1;
}
}
cout << out;
return 0;
}