PROBLEM LINK:
Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4
Author: Aatman Supkar
Testers: Jeevan Jyot Singh, Hriday
Editorialist: Nishank Suresh
DIFFICULTY:
373
PREREQUISITES:
None
PROBLEM:
P passengers are traveling on a train, and they have Q tickets between them. Each person can have 0 or 1 ticket.
Each person without a ticket pays a fine of rupees X. How much will be paid in fines?
EXPLANATION
Of the P passengers, P - Q do not have a ticket. Each of them will pay X, so a total of (P-Q)\cdot X will be collected.
TIME COMPLEXITY
\mathcal{O}(1) per test case.
CODE:
Editorialist's code (Python)
for _ in range(int(input())):
x, p, q = map(int, input().split())
print(x*(p-q))