Summer Heat Codechef Solution

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.

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.

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

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.

Summer Heat   – CodeChef Solution in JAVA

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc = new Scanner(System.in);
		if(sc.hasNextInt()){
		    int testCases = sc.nextInt();
		    while(testCases-- >0){
		        int x = sc.nextInt();
		        int y = sc.nextInt();
		        int X_type = sc.nextInt();
		        int Y_type = sc.nextInt();
		        
		        int x_count = (X_type/x);
		        int y_count = (Y_type/y);
		        
		        int totalSum = x_count+y_count;
		        System.out.println(totalSum);
		    }
		}
	}
}

Summer Heat – CodeChef Solution in CPP

#include <iostream>
using namespace std;
int main()
{
    int t, xa, xb, ya, yb, water, pulp;
    cin >> t;
    while (t--)
    {
        cin >> xa >> xb >> ya >> yb;
        water = ya / xa;
        pulp = yb / xb;
        cout << water + pulp << endl;
    }
    return 0;
}

Summer Heat -CodeChef Solution in Python

T = int(input())

for i in range(T):
    (x_a,x_b,X_a,X_b) = map(int,input().split())
    N_a = X_a//x_a
    N_b = X_b//x_b
    print(N_a+N_b)

Disclaimer: The above Problem (Summer Heat ) is generated by CodeChef but the solution is provided by Codeworld19.This tutorial is only for Educational and Learning purpose.

Leave a Reply

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