GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Wednesday 2 November 2022

[Solution] Tasty Decisions CodeChef Solution




Problem

Chef is buying sweet things to prepare for Halloween!

The shop sells both chocolate and candy.

  • Each bar of chocolate has a tastiness of X.
  • Each piece of candy has a tastiness of Y.

One packet of chocolate contains 2 bars, while one packet of candy contains 5 pieces.

Chef can only buy one packet of something sweet, and so has to make a decision: which one should he buy in order to maximize the total tastiness of his purchase?

Print Chocolate if the packet of chocolate is tastier, Candy if the packet of candy is tastier, and Either if they have the same tastiness.

Input Format

  • The first line of input will contain a single integer T, denoting the number of test cases.
  • Each test case consists of one line of input, containing two space-separated integers X and Y — the tastiness of one bar of chocolate and one piece of candy, respectively.

Output Format

For each test case, output on a new line the answer:

  • Chocolate if the packet of chocolate is tastier.
  • Candy if the packet of candy is tastier.
  • Either if they have the same tastiness.

You may print each character of the output in either uppercase or lowercase, i.e, CandyCANDYCaNdY and cANDy will all be treated as equivalent.

Explanation:

Test case 1: The packet of chocolate has a tastiness of 2\times 5 = 10, while the packet of candy has a tastiness of 5\times 1 = 5. The chocolate is tastier.

Test case 2: The packet of chocolate has a tastiness of 2\times 5 = 10, while the packet of candy has a tastiness of 5\times 2 = 10. They have the same tastiness.

Test case 3: The packet of chocolate has a tastiness of 2\times 5 = 10, while the packet of candy has a tastiness of 5\times 3 = 15. The candy is tastier.

Test case 4: The packet of chocolate has a tastiness of 2\times 3 = 6, while the packet of candy has a tastiness of 5\times 10 = 50. The candy is tastier.

No comments:

Post a Comment