GUPTA MECHANICAL

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

Wednesday 31 August 2022

[Solution] Ticket Fine CodeChef Solution | Solution CodeChef



Problem

On a certain train, Chef-the ticket collector, collects a fine of Rs. X if a passenger is travelling without a ticket. It is known that a passenger carries either a single ticket or no ticket.

P passengers are travelling and they have a total of Q tickets. Help Chef calculate the total fine collected.

Input Format

The first line contains a single integer T, the number of test cases. T lines follow. Each following line contains three integers separated by spaces, whose description follows.

  • The first integer, X, is the fee in rupees.
  • The second integer, P, is the number of passengers on the train.
  • The third integer, Q, is the number of tickets Chef collected.

Output Format

The output must consist of T lines.

  • The i^{th} line must contain a single integer, the total money(in rupees) collected by Chef corresponding to the i^{th} test case.

Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇

Explanation:

Test case 1: The total number of passengers travelling without ticket are 1 - 1 = 0. So the total fine collected is 0 \cdot 4 = 0 rupees.

Test case 2: The total number of passengers travelling without ticket are 10 - 7 = 3. So the total fine collected is 3 \cdot 2 = 6 rupees.

Test case 3: The total number of passengers travelling without ticket are 5 - 4 = 1. So the total fine collected is 1 \cdot 8 = 8 rupees.

Test case 4: The total number of passengers travelling without ticket are 7 - 0 = 7. So the total fine collected is 7 \cdot 9 = 63 rupees.

No comments:

Post a Comment