Apply a Discount

Easy · rating 950 · math

An online store applies a percentage discount to a price. Read two integers on one line: the price p in cents and the discount d as a whole percentage (0–100). Print the final price in cents, rounding down to the nearest cent.

Constraints: 0 ≤ p ≤ 109, 0 ≤ d ≤ 100

Editorial

Apply a Discount reduces a price by a whole-percent discount, rounding down. Compute price · (100 − d) / 100 with integer division to stay exact in cents.

print(price * (100 - d) // 100)

Complexity

Time: O(1). Space: O(1).

Open Apply a Discount in Code Arena →