GUPTA MECHANICAL

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

Friday, 9 September 2022

[Solution] Bob at the Bank CodeChef Solution



Problem

Bob has an account in the Bobby Bank. His current account balance is W rupees.

Each month, the office in which Bob works deposits a fixed amount of X rupees to his account.
Y rupees is deducted from Bob's account each month as bank charges.

Find his final account balance after Z months. Note that the account balance can be negative as well. 

Input Format

  • The first line will contain T, the number of test cases. Then the test cases follow.
  • Each test case consists of a single line of input, containing four integers W,X,Y, and Z — the initial amount, the amount deposited per month, the amount deducted per month, and the number of months.

Output Format

For each test case, output in a single line the final balance in Bob's account after Z months.

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

Explanation:

Test case 1: Bob's current account balance is 100. At the end of each month Bob gets Rs 11 and pays Rs 1, thus gaining 10 per month. Thus, at the end of 10 months, Bob will have 100 + 10 \times 10 = 200.

Test case 2: Bob's current account balance is 999. At the end of each month Bob gets Rs 25 and pays Rs 36, thus losing 11 per month. Thus, at the end of 9 months, Bob will have 999 - 11 \times 9 = 900.

Test case 3: Bob's current account balance is 2500. At the end of each month Bob gets Rs 100 and pays Rs 125, thus losing 25 per month. Thus, at the end of 101 months, Bob will have 2500 - 25 \times 101 = -25.

No comments:

Post a Comment