Summer Heat: COCONUT

CU Submission link: Click here

Public Submission link: Click here

Summer Heat codechef solution

Read problem statements in Vietnamese,

BengaliMandarin Chinese, and Russian as well.

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 1 

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

Sample Output 1 

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 C++ 17

int main() {
	int t;
	cin>>t;
	while(t--)
	{
	    int a,b,c,d;
	    cin>>a>>b>>c>>d;
	    int sum;
	    sum=(c/a)+(d/b);
	    cout<< sum<< endl;
	}
	return 0;
}

Summer Heat Codechef Solution in Python 3

# cook your dish here
for _ in range(int(input())):
    a,b,c,d=map(int,input().split())
    print((c//a)+(d//b))

Summer Heat Codechef Solution in 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 n = sc.nextInt();
		for(int i = 0 ; i< n ; i++)
		{
		    int a = sc.nextInt();
		    int b = sc.nextInt();
		    int c = sc.nextInt();
		    int d = sc.nextInt();
		    int m = (c/a) + (d/b);
		    System.out.println(m);
		}
	}
}


Summer Heat Codechef Solution by

Summer Heat Codechef Solution
Summer Heat Codechef Solution
See also  Area OR Perimeter: AREAPERI