Summer Heat CodeChef Solution | COCONUT

Hello coders, today we are going to solve Summer Heat CodeChef Solution whose Problem code is COCONUT in C++, Java and Python.

Summer Heat CodeChef Solution

Task

Chefland has 2 different types of coconut, type A and type B. Type A contains only xa milliliters of coconut water and type B contains only xb grams of coconut pulp. Chef’s nutritionist has advised him to consume Xa milliliters of coconut water and Xb 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 T, the number of test cases. Then the test cases follow.
  • Each test case contains a single line of input, four integers xa, xb, Xa, Xb.

Output Format

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

Constraints

  • 1 ≤ T ≤ 15000
  • 100 ≤ xa ≤ 200
  • 400 ≤ xb ≤ 500
  • 1000 ≤ Xa ≤ 1200
  • 1000 ≤ Xb ≤ 1500
  • xa divides Xa.
  • xb divides Xb.

Subtasks #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 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/150=8 and number of coconuts of Type B required = 1200/400=3. So the total number of coconuts required is 8+3=11.

Solution – Summer Heat CodeChef Solution

C++

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int t; cin>>t;
	while(t--){
	    int a,b,x,y;
	    cin >> a >> b >> x >> y;
	    cout << (x/a)+(y/b) <<"\n";
	}
	return 0;
}

Java

/* package codechef; // don't place package name! */

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);
		int t = sc.nextInt();
		while(t-- >0){
		    
		    int a,b,x,y;
		    a = sc.nextInt();
		    b = sc.nextInt();
		    x = sc.nextInt();
		    y = sc.nextInt();
		    System.out.println((x/a)+(y/b));
		}
	}
}

Python

# cook your dish here
T = int(input())
for i in range(T):
    a, b, x, y = map(int, input().split())
    print((x//a) + (y//b))

Disclaimer: The above Problem (Summer Heat) is generated by CodeChef but the Solution is Provided by CodingBroz. This tutorial is only for Educational and Learning Purpose.

Leave a Comment

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