Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

KJSCE/IT Minor/SYBTECH/SEM IV/CPL/2021-22

Experiment No. 3

Title: Implementation of arithmetic operations

(A Constituent College of Somaiya Vidyavihar University)


KJSCE/IT Minor/SYBTECH/SEM IV/CPL/2021-22

Batch: B1 Roll No: 16010320032 Experiment No.:3

Aim: To study the arithmetic operation and verify given test cases.

Resources needed: Text Editor, Hackereath platform

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

(A Constituent College of Somaiya Vidyavihar University)


KJSCE/IT Minor/SYBTECH/SEM IV/CPL/2021-22

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];

if (N[i] % K[i] > 0)


{
x++;
}

(A Constituent College of Somaiya Vidyavihar University)


KJSCE/IT Minor/SYBTECH/SEM IV/CPL/2021-22

y = M[i] / K[i];
if (M[i] % K[i] > 0)
{
y++;
}
printf("%d \n", x + y);
}
return 0;
}

(A Constituent College of Somaiya Vidyavihar University)


KJSCE/IT Minor/SYBTECH/SEM IV/CPL/2021-22

Output:

Test Result:

(A Constituent College of Somaiya Vidyavihar University)


KJSCE/IT Minor/SYBTECH/SEM IV/CPL/2021-22

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

Conclusion: (Conclusion to be based on the objectives and outcomes achieved)


We understood the problem statement and input format. We wrote the program depending
upon the output required and tested the code for every test case. We submitted the code and
all test cases were passed by the HackerEarth platform.

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

(A Constituent College of Somaiya Vidyavihar University)

You might also like