Christmas Gifts
Source: codechef
Difficulty: 574

Christmas Gifts
Chef is wrapping Christmas gifts for his friends. He has a rectangular sheet of wrapping paper with a total area of$1000$square centimeters. Each identical gift is a rectangular box with dimensions:
Height$(H)$centimeters
Length$(L)$centimeters
Width$(W)$centimeters
To wrap a gift, Chef needs enough paper to cover all six faces of the box, with no overlapping or gaps. Calculate the
maximum
number of complete gifts Chef can wrap using the available wrapping paper.
Input Format
The first line of input will contain a single integer$T$, denoting the number of test cases.
Each test case consists of three space-separated integers$H, L$and$W$— the dimensions of each gift box.
Output Format
For each test case, output on a new line, the
maximum
number of complete gifts Chef can wrap using the available wrapping paper.
Constraints$1 \leq T \leq 1000$$1 \leq H, L, W \leq 10$Sample 1:
Explanation:
Test case$1$:
With given dimensions, surface area of one gift is$2\cdot (1\cdot 1 + 1\cdot 2 + 1\cdot 2) = 10$sq cm. Thus, Chef can wrap a total of$100$gifts.
Test case$2$:
With given dimensions, surface area of one gift is$2\cdot (4\cdot 2 + 2\cdot 6 + 6\cdot 4) = 88$sq cm. Thus, Chef can wrap a total of$11$gifts.
Test case$3$:
With given dimensions, surface area of one gift is$2\cdot (10\cdot 2 + 2\cdot 4 + 10\cdot 4) = 136$sq cm. Thus, Chef can wrap a total of$7$gifts.

Sample Input:
3
1 1 2
4 2 6
10 2 4

Sample Output:
100
11
7

C++ solution:
#include <bits/stdc++.h>
using namespace std;

int main() {
    // your code goes here
    int t;
    cin>>t;
    int h,l,w;
    while(t--){
        cin>>h>>l>>w;
        int c=0;
        c=2*(h*l+l*w+w*h);
       
        cout<<1000/c<<endl;
    }

}

Go solution:
package main
import "fmt"

func main(){
    // your code goes here
    var t, l, b, h int
    fmt.Scan(&t)

    for i := 0; i<t; i++ {
        fmt.Scan(&l, &b, &h)
        fmt.Println(1000/(2*(l*b + b*h + h*l)))
    }
}

Java solution:
import java.util.*;
import java.lang.*;
import java.io.*;

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 h=sc.nextInt();
            int l=sc.nextInt();
            int w=sc.nextInt();
            int r=2*(h*l+l*w+w*h);
            int res=1000/r;
            System.out.println(res);
            
        }

    }
}

JavaScript solution:
process.stdin.setEncoding('utf8');
let num = "";
process.stdin.on('data', function(input){
    num += input;
});
process.stdin.on('end', function(){
    let lines = num.trim().split("\n");
    let T = parseInt(lines[0]);
    for(let i = 1; i<=T; i++){
        let [H, L, W] = lines[i].trim().split(" ").map(Number);
        let P = 2*(H*L+L*W+W*H);
        let total = Math.floor(1000/P);
        console.log(total);
    }
})

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

Ruby solution:
# Read number of test cases
num_test_cases = gets.to_i

# Process each test case
num_test_cases.times do
  # Read and parse dimensions
  dimensions = gets.chomp.split.map(&:to_i)
  height, length, width = dimensions[0], dimensions[1], dimensions[2]

  # Calculate surface area
  surface_area = 2 * (height * length + length * width + width * height)

  # Calculate maximum number of gifts (ensure no division by zero)
  max_gifts = surface_area.zero? ? 0 : 1000 / surface_area

  # Output result
  puts max_gifts
end