Discounted Price
Easy · rating 950 · Math
An item costs price cents and is on sale at pct percent off. Read the two space-separated integers price and pct and print the sale price in cents, with the discount rounded down to a whole cent.
Constraints: 0 ≤ price ≤ 109, 0 ≤ pct ≤ 100
Editorial
Approach
The amount discounted is price × pct ÷ 100, floored to a whole cent; the sale price is the original minus that. Equivalently you can keep (100 − pct) percent, but subtracting the floored discount matches the stated rounding exactly.
price, pct = map(int, input().split())
print(price - price * pct // 100)Complexity
Time: O(1). Space: O(1).
Related problems
- Apply a Discount — Easy
- Leap Year — Easy
- Plus One — Easy
- Product of Digits — Easy
- Spend and Save — Easy
- Sum of Digits — Easy