Submit | All submissions | Best solutions | Back to list |
EIUBALANCE - Balance life and work |
Quynh kept working for M months, then took M months unpaid leave to travel for vacation.
Let's calculate Quynh's savings after M months of unpaid travel, knowing that:
- Quynh’s salary of M months as Mi, where i ranges from 0 to M-1.
- After receiving her monthly salary, Quynh spends X USD on expenses. The monthly expenses increase according to an annual inflation rate of f% which is estimated by: X[i+1] = X[i]*(1+f%/12)
- Quynh invests the surplus amount each month with an annual interest rate of r% which can be calculated using the formula: SaveMoney[i+1] = SaveMoney[i]*(1+r%/12).
Input
- The number of months M (M ≤ 500), the amount of money earning per each month Mi USD as i = {1,…,M} (Mi ≤ 109), the monthly expenditure X USD (X ≤ 109), the yearly inflation rate f%, the yearly interest rate r%.
Output
- The amount of saving money remains after M months to traveling. If saving money is negative return 0. The result is rounded to unit.
Sample
Input |
Output |
1 1500 500 12 12 |
510 |
Added by: | Ha Minh Ngoc |
Date: | 2024-06-25 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | CSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG FSHARP GO JAVA JS-MONKEY NODEJS PHP PYTHON PYPY PYPY3 PYTHON3 RUBY SQLITE SWIFT VB.NET |