PIZZACOMP - Editorial

PROBLEM LINK:

Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4

Author: raysh07
Tester: sushil2006
Editorialist: iceknight1093

DIFFICULTY:

TBD

PREREQUISITES:

None

PROBLEM:

There are two types of square pizza: a 10-inch one costing A rupees, and a 15-inch one costing B rupees.
Which one is better value for money?

EXPLANATION:

The 10-inch pizza has an area of 10\times 10 = 100 square inches, while the 15-inch pizza has an area of 15\times 15 = 225 square inches.

So,

  • The 10-inch pizza, costing A rupees, gives \frac{100}{A} pizza per rupee.
  • The 15-inch pizza, costing B rupees, gives \frac{225}{B} pizza per rupee.

Thus,

  • If \frac{100}{A} \gt \frac{225}{B}, the smaller pizza provides more value per rupee.
  • If \frac{100}{A} \lt \frac{225}{B}, the larger pizza provides more value per rupee.
  • If \frac{100}{A} = \frac{225}{B}, the value provided is equal.

TIME COMPLEXITY:

\mathcal{O}(1) per testcase.

CODE:

Editorialist's code (PyPy3)
for _ in range(int(input())):
    a, b = map(int, input().split())
    
    small = 100 / a
    large = 225 / b
    if small > large: print('Small')
    elif large > small: print('Large')
    else: print('Equal')