B1 16010320032 CPL Exp3
B1 16010320032 CPL Exp3
B1 16010320032 CPL Exp3
Experiment No. 3
Aim: To study the arithmetic operation and verify given test cases.
Theory:
For the problem statement given the activity section, the following formula can be used
Where F represents the total number of rooms required. Other nomenclatures are explained in the
problem statement.
Activity:
Consider the following problem statement and other information provided along with it:
Problem Statement:
A group of students wants to visit a tour in some city. In total, the group has N boys and M girls.
To do this, they need to stay in a hotel.
Calculate the number of rooms you need to book in the hotel, if each hotel room has K seats,
provided that the boys can not live with the girls in the same room.
Input format
The first line specifies a number T denoting the number of test cases.
In each line of the test case, there are three numbers N,M,K.
Output format
For each test case, print one number denoting the number of rooms to be booked at the hotel.
Constraints
Sample Input
4
13 7 2
553
222
545
Sample Output
11
4
2
2
Time Limit: 1
Memory Limit: 256
Program:
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int T;
scanf("%d", &T);
int N[1000], M[1000] = {};
int K[1000];
for (int i = 0; i < T; i++)
{
scanf("%d %d %d", &N[i], &M[i], &K[i]);
}
int x, y = 0;
for (int i = 0; i < T; i++)
{
x = N[i] / K[i];
y = M[i] / K[i];
if (M[i] % K[i] > 0)
{
y++;
}
printf("%d \n", x + y);
}
return 0;
}
Output:
Test Result:
Outcomes:
Inculcate the best practices that are essential for competitive programming and the
fundamental concepts for managing the data.
Learn effective computation and programming practices for numeric and string
operations and computation geometry
References:
1. https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-
implementation/practice-problems/algorithm/excursion-2d080f3a/
2. T.H. Coreman ,C.E. Leiserson,R.L. Rivest, and C. Stein, " Introduction to algorithms",
3rd Edition 2009, Prentice Hall India Publication
3. Antti Laaksonen, “Guide to Competitive Programming”,Springer,2018
4. Gayle Laakmann McDowell,” Cracking the Coding Interview”,CareerCup LLC,2015
5. Steven S. Skiena Miguel A. Revilla,”Programming challenges, The Programming
Contest Training Manual”, Springer, 2006
6. Antti Laaksonen, “Competitive Programmer’s Handbook”, Hand book, 2018
7. Steven Halim and Felix Halim, “Competitive Programming 3: The Lower Bounds of
Programming Contests”, Handbook for ACM ICPC