BOBBANK - Editorial

Author: S. Manuj Nanthan
Testers: Satyam, Jatin Garg
Editorialist: Nishank Suresh

481

None

PROBLEM:

Bob’s current bank balance is W rupees. Each month, rupees X is deposited into it and Y is deducted. How much remains in it after Z months?

EXPLANATION:

Each month, X rupees is added and Y is deducted, leading to an overall change of X-Y in his balance.
In Z months, this amounts to a total change of Z\times(X-Y).

So, the final balance is W + Z\times(X-Y).

TIME COMPLEXITY

\mathcal{O}(1) per test case.

CODE:

Editorialist's code (Python)
for _ in range(int(input())):
w, x, y, z = map(int, input().split())
print(w + z*(x-y))