[Solution] Bob at the Bank CodeChef Solution
Problem
Bob has an account in the Bobby Bank. His current account balance is rupees.
Each month, the office in which Bob works deposits a fixed amount of rupees to his account.
rupees is deducted from Bob's account each month as bank charges.
Find his final account balance after months. Note that the account balance can be negative as well.
Input Format
- The first line will contain , the number of test cases. Then the test cases follow.
- Each test case consists of a single line of input, containing four integers and — 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 months.
Explanation:
Test case : Bob's current account balance is . At the end of each month Bob gets Rs and pays Rs , thus gaining per month. Thus, at the end of months, Bob will have .
Test case : Bob's current account balance is . At the end of each month Bob gets Rs and pays Rs , thus losing per month. Thus, at the end of months, Bob will have .
Test case : Bob's current account balance is . At the end of each month Bob gets Rs and pays Rs , thus losing per month. Thus, at the end of months, Bob will have .
No comments:
Post a Comment