Codechef: June Challenge | Summer Heat | COCONUT | Solution

Codechef

View on Codechef

Chefland has 22 different types of coconut, type AA and type BB. Type AA contains only xaxa milliliters of coconut water and type BB contains only xbxb grams of coconut pulp. Chef’s nutritionist has advised him to consume XaXa milliliters of coconut water and XbXb grams of coconut pulp every week in the summer. Find the total number of coconuts (type AA + type BB) that Chef should buy each week to keep himself active in the hot weather.

For the work from home Internship Programs : Click here to apply now

Input

  • 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 xaxa, xbxb, XaXa, XbXb.

Output

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

Constraints

  • 1≤T≤150001≤T≤15000
  • 100≤xa≤200100≤xa≤200
  • 400≤xb≤500400≤xb≤500
  • 1000≤Xa≤12001000≤Xa≤1200
  • 1000≤Xb≤15001000≤Xb≤1500
  • xaxa divides XaXa.
  • xbxb divides XbXb.

Codechef Subtasks

Subtask #1 (100 points): original constraints

Sample Input

3
100 400 1000 1200
100 450 1000 1350
150 400 1200 1200

Sample Output

13
13
11

Codechef Explanation

TestCase 11: Number of coconuts of Type AA required = 1000100=101000100=10 and number of coconuts of Type BB required = 1200400=31200400=3. So the total number of coconuts required is 10+3=1310+3=13.

TestCase 22: Number of coconuts of Type AA required = 1000100=101000100=10 and number of coconuts of Type BB required = 1350450=31350450=3. So the total number of coconuts required is 10+3=1310+3=13.

TestCase 33: Number of coconuts of Type AA required = 1200150=81200150=8 and number of coconuts of Type BB required = 1200400=31200400=3. So the total number of coconuts required is 8+3=118+3=11.

Due to copyright issues we won't be able to update the solution here immediately. However you can download the code file from our telegram channel. So join our telegram channel for further updates. Keep tracking, the solution will be updated on this website soon.
  • HACKEREARTH IS HIRING FOR INTERN || APPLY NOW
  • INTEL IS HIRING FOR SOFTWARE DEVELOPER INTERN || APPLY Now
  • DATA SCIENCE INTERNSHIP | SONY RESEARCH INDIA || APPLY NOW

Read more post Here

Leave a Comment

Your email address will not be published. Required fields are marked *

x