ABC Bank’s customer Aaron downloads his Savings account’s transaction ledger for R days which has R rows in the following format:
<credit / debit>
The transaction id is a sequential number From 1 to R, and the initial balance (before the first day) in Aaron’s account is zero
The ledger is sorted by date and spans over a period of R days. The last date in the ledger provides Aaron with the total savings account interest accrued over the year, at the daily rate of A% per annum (taken to be 365 days). This also shows in the remark field as “Interest for R days”. Interest is calculated on a daily basis and is not credited back to the balance.
Aaron notices that two consecutive rows in the ledger are fully corrupted and despite repeated downloads he cannot get proper data for these two rows. These are two rows outside of the last row which is labeled “Interest for R days”. The two corrupted rows are represented by gaps in the id numbers.
Write a program to help Aaron to find the value of the two corrupted rows i.e. <credit / debit>
0 < amount < 1000
5 < R < 365
The first line contains a decimal A which denotes the rate of interest per annum (expressed as a percentage). A year is taken as 365 days.
The second line contains an integer R that denotes the total number of rows that should have been there in the Account Statement.
The next (R-2) lines contain the transaction details of the format <credit / debit> delimited by a single space character where
- An integer that represents the transaction id
- An integer that represents the amount transacted
<credit / debit> - Represents the type of transactions i.e. either credit or debit
- An integer that represents balance in account after the transaction has completed
The last line contains a high precision decimal number that denotes the total sum of interest earned at the end of the last day of transaction.
2 lines containing the corrupted transaction details in the format:
<credit / debit>
Where Amount and Balance are numbers rounded to the nearest integer.
1 355 credit 355
2 202 debit 153
3 59 debit 94
4 31 debit 63
7 355 debit 261
8 253 credit 514
9 308 debit 206
10 69 debit 137
5 314 credit 377
6 239 credit 616
A=8 (the interest rate is 8% per annum)
R is 10 (10 days)
The rate of Interest is 8% per annum. In 10 days Aaron generated interest of 0.6084383561643835.
Since, rows 5 and 6 do not appear in the input, consider them as corrupted. Upon calculation the corrupted rows are as shown in the output.