PROBLEM LINK:
Author: Abhijeet Trigunait
Tester: Abhijeet Trigunait
DIFFICULTY:
Easy.
PREREQUISITES:
Math.
PROBLEM:
One day Chef decided to visit his friend. It turned out that the Chef’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 Chef 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.
EXPLANATION:
Given starting point 0 and ending point N.Chef can step forward maximum 1,2,3,4 or 5 ,so the best way to reach N is to use the highest possible step i.e 5 .
Maximum times step 5 can be used is given by N/5,and N% 5 would definetely be less than 5,so it would cost one step more. So the maximum steps used to reach N is-(N/5+1).
SOLUTIONS:
Setter's Solution
#include <iostream>
using namespace std;
int main() {
int t;
cin>>t;
while(t--){
int x;
cin >> x;
cout << (x/5+1)<< '\n';
}}