Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
A single car can accommodate at most 4 people.
N friends want to go to a restaurant for a party. Find the minimum number of cars required to accommodate all the friends.
For each test case, output the minimum number of cars required to accommodate all the friends.
Input: 4
4
2
7
98
Output: 1
1
2
25
Test Case 1: There are only 4 friends and a single car can accommodate 4 people. Thus, only 1 car is required.
Test Case 2: There are only 2 friends and a single car can accommodate 4 people. Thus, only 1 car is required
Test Case 3: There are 7 friends and 2 cars can accommodate 8 people. Thus, 2 cars are required.
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
int T=sc.nextInt();
for(int i=0;i<T;i++)
{
int x=sc.nextInt();
int a=x%4;
int b=x/4;
if(a==0)
System.out.println(b);
else
System.out.println(b+1);
}
}
}
# cook your dish here
n=int(input())
for i in range(0,n):
e=int(input())
d=e%4
if(d<4 and d!=0):
print((e//4)+1)
elif(d==0):
print(e//4)
#include <iostream>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t--){
int n;
cin>>n;
// cout<<n*2<<endl;
if(n%4==0)
{
cout<<(n/4)<<endl;
}
else{
cout<<(n/4)+1<<endl;
}
}
return 0;
}
In our experience, we suggest you solve this Minimum Cars required CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
If you are stuck anywhere between any coding problem, just visit Queslers to get the Minimum Cars required CodeChef Solution
I hope this Minimum Cars required CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.
This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.
Keep Learning!
More Coding Solutions >>