Please Fill out the Feedback Form for Code Radius

Summer Heat : COCONUT | CodeChef Solution

2 min read

 

Problem

Chefland has 2 different types of coconut, type A and type B. Type A contains only x_a milliliters of coconut water and type B contains only x_b grams of coconut pulp. Chef's nutritionist has advised him to consume X_a milliliters of coconut water and X_b grams of coconut pulp every week in the summer. Find the total number of coconuts (type A + type B) that Chef should buy each week to keep himself active in the hot weather.

Input Format

The first line contains an integer TT, the number of test cases. Then the test cases follow.
Each test case contains a single line of input, four integers x_a, x_b, X_a, X_b.

Output Format

For each test case, output in a single line the answer to the problem.

Constraints

Sample

Input
3
100 400 1000 1200
100 450 1000 1350
150 400 1200 1200
Output
13
13
11

Explanation

TestCase 1: Number of coconuts of Type A required = 1000/100 = 10 and number of coconuts of Type B required = 1200/400 = 3. So the total number of coconuts required is 10 + 3 = 13.
TestCase 2: Number of coconuts of Type A required = 1000/100 = 10 and number of coconuts of Type B required = 1350/450 = 3 . So the total number of coconuts required is 10 + 3 = 13.
TestCase 3: Number of coconuts of Type A required = 1200/400 = 8 and number of coconuts of Type B required = 1200/400 = 3. So the total number of coconuts required is 8 + 3 = 11.

Solution

cpp
#include <iostream> using namespace std; // Solution from : Code Radius [ https://radiuscode.blogspot.com/ ] int main() { int t; cin>>t; while(t--){ int a,b,A,B; cin>>a>>b>>A>>B; cout<<A/a+B/b<<endl; } return 0; }
Please First Try to Solve Problem by Yourself.

You may like these posts

  • Problem In mathematics, the degree of polynomials in one variable is the highest power of the variable in the algebraic expression with non-zero coefficient.Chef has a polynomial…
  •  ProblemChef is a big fan of Coldplay. Every Sunday, he will drive to a park taking M minutes to reach there, and during the ride he will play a single song on a loop. Today, …
  • ProblemAlice and Bob are meeting after a long time. As usual they love to play some math games. This times Alice takes the call and decides the game. The game is very simple, Alice…
  • ProblemIf Give an integer N . Write a program to obtain the sum of the first and last digits of this number. Please Share this article... Input Format The first line contains a…
  •  ProblemChefland has 2 different types of coconut, type A and type B. Type A contains only x_a milliliters of coconut water and type B contains only x_b grams of coconut pulp.…
  • ProblemYou and your friend are playing a game with hoops. There are N hoops (where N is odd) in a row. You jump into hoop 1, and your friend jumps into hoop N. Then you jump into h…

Post a Comment