Skip to content

SAASIMAHMEDW/CPP-PROGRAMS

Repository files navigation

CPP-PROGRAMS

  1. Agastya is currently standing at stair 00 and he wants to reach stair numbered XX. Agastya can climb either YY steps or 11 step in one move. Find the minimum number of moves required by him to reach exactly the stair numbered XX. Input Format The first line of input will contain a single integer TT, denoting the number of test cases. Each test case consists of a single line of input containing two space separated integers XX and YY denoting the number of stair Agastya wants to reach and the number of stairs he can climb in one move. Output Format For each test case, output the minimum number of moves required by him to reach exactly the stair numbered XX.

  2. You are given the height H (in metres) and mass M (in kilograms). The Body Mass Index (BMI) of a person is computed as 𝑀 𝐻2 . Report the category into which a person falls, based on his BMI: • Category 1: Underweight if 𝐵𝑀𝐼 ≤ 18 • Category 2: Normal weight if𝐵𝑀𝐼 ∈ {19, 20, … , 24} • Category 3: Overweight if 𝐵𝑀𝐼 ∈ {25, 26, … , 29} • Category 4: Obesity if 𝐵𝑀𝐼 ≥ 30 Input: The first line of input will contain an integer, TT, which denotes the number of testcases. Then the testcases follow. Each testcase contains a single line of input, with two space separated integers, M, H, which denote the mass and height of Agastya respectively. Output: For each testcase, output in a single line, 1, 2, 31,2,3 or 44, based on the category in which Agastya falls.

  3. You will be given an array of N integers and you have to print the integers in the reverse order. Input Format The first line of the input contains N, where N is the number of integers. The next line contains N space-separated integers.

  4. Bhuvan has a string S with him. Bhuvan is happy if the string contains a contiguous substring of length strictly greater than 2 in which all its characters are vowels. Determine whether Bhuvan is happy or not. Note that, in English alphabet, vowels are a, e, i, o, and u. Input Format First line will contain T, number of test cases. Then the test cases follow. Each test case contains of a single line of input, a string S. Output Format For each test case, if Bhuvan is happy, print HAPPY else print SAD. You may print each character of the string in uppercase or lowercase (for example, the strings hAppY, Happy, haPpY, and HAPPY will all be treated as identical))

  5. There is a group of N friends who wish to enroll in a course together. The course has a maximum capacity of M students that can register for it. If there are K other students who have already enrolled in the course, determine if it will still be possible for all the N friends to do so or not. Input Format • The first line contains a single integer T - the number of test cases. Then the test cases follow. • Each test case consists of a single line containing three integers N, M and K - the size of the friend group, the capacity of the course and the number of students already registered for the course. Output Format For each test case, output Yes if it will be possible for all the N friends to register for the course. Otherwise output No. You may print each character of Yes and No in uppercase or lowercase (for example, yes, yEs, YES will be considered identical).

  6. Chetan is playing a videogame, and is getting close to the end. He decides to finish the rest of the game in a single session. There are X levels remaining in the game, and each level takes Chetan Y minutes to complete. To protect against eye strain, Chetan also decides that every time he completes 3 levels, he will take a Z minute break from playing. Note that there is no need to take this break if the game has been completed. How much time (in minutes) will it take Chetan to complete the game? Input Format • The first line of input will contain a single integer T, denoting the number of test cases. • The first and only line of input will contain three space-separated integers X, Y, and Z. Output Format For each test case, output on a new line the answer — the length of Chetan’s gaming session.

  7. Dhruv is very fond of horses. He enjoys watching them race. As expected, he has a stable full of horses. He, along with his friends, goes to his stable during the weekends to watch a few of these horses race. Agastya wants his friends to enjoy the race and so he wants the race to be close. This can happen only if the horses are comparable on their skill i.e. the difference in their skills is less. There are N horses in the stable. The skill of the horse i is represented by an integer S[i]. Dhruv needs to pick 2 horses for the race such that the difference in their skills is minimum. This way, he would be able to host a very interesting race. Your task is to help him do this and report the minimum difference that is possible between 2 horses in the race. Input: First line of the input file contains a single integer T, the number of test cases. Every test case starts with a line containing the integer N. The next line contains N space separated integers where the i-th integer is S[i]. Output: For each test case, output a single line containing the minimum difference that is possible.

  8. There is a frog initially placed at the origin of the coordinate plane. In exactly 1 second, the frog can either move up 1 unit, move right 1 unit, or stay still. In other words, from position (x,y), the frog can spend 1 second to move to: • (x+1,y) • (x,y+1) • (x,y) After T seconds, a villager who sees the frog reports that the frog lies on or inside a square of side-length s with coordinates (X,Y), (X+s,Y), (X,Y+s), (X+s,Y+s). Calculate how many points with integer coordinates on or inside this square could be the frog's position after exactly T seconds Input Format: The first and only line of input contains four space-separated integers: X, Y, s, and T. Output Format: Print the number of points with integer coordinates that could be the frog's position after T seconds. There are N students in a class, where the i-th student has a score of Ai.

  9. The i-th student will boast if and only if the number of students scoring less than or equal to Ai is greater than the number of students scoring greater than Ai. Find the number of students who will boast. Input Format • The first line contains T - the number of test cases. Then the test cases follow. • The first line of each test case contains a single integer N - the number of students. • The second line of each test case contains N integers 1,2,…,A1,A2,…,AN - the scores of the students. Output Format For each test case, output in a single line the number of students who will boast.9.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages