#CCBOTPBA0000064. Khấu hao tài sản theo ba phương pháp (Asset Depreciation by Three Methods)

Khấu hao tài sản theo ba phương pháp (Asset Depreciation by Three Methods)

Asset Depreciation by Three Methods

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem Statement

An asset has an initial value VV and an expected life of nn years. Depreciation is deducted from its remaining value, initially VV. Choose one method using code mm:

  • m=1m=1 — Straight line: deduct the constant amount V/nV/n each year.
  • m=2m=2 — Declining balance: deduct 2/n2/n times the remaining value at the beginning of the current year.
  • m=3m=3 — Sum of years: let S=1+2+⋯+nS=1+2+\cdots+n. During year ii (numbered starting from 11), deduct V(n−i+1)/SV(n-i+1)/S based on the original value.

Print the remaining value after each year in order. Keep unrounded intermediate values and round only each printed value. For methods 1 and 3, the remaining value after the final year is defined as zero to eliminate tiny floating-point artifacts.

Input

One line contains the real value VV and the integers nn and mm, in that order. VV is the initial asset value, nn is the number of years and mm chooses the method.

Output

Print exactly nn lines. Line ii contains the integer ii, one space, and the remaining value immediately after year ii, formatted with exactly two decimal digits. Do not print column headings or a currency symbol.

Subtasks

  • Subtask 1 (20%): 0<V≤106, 2≤n≤100, m=10<V\le10^6,\ 2\le n\le100,\ m=1.
  • Subtask 2 (30%): 0<V≤106, 2≤n≤100, m∈{1,2}0<V\le10^6,\ 2\le n\le100,\ m\in\{1,2\}.
  • Subtask 3 (50%): 0<V≤106, 2≤n≤100, m∈{1,2,3}0<V\le10^6,\ 2\le n\le100,\ m\in\{1,2,3\}.

Examples

Example 1

Input:

100 4 1

Output:

1 75.00
2 50.00
3 25.00
4 0.00

Explanation: The fixed annual deduction is 100/4 = 25. The remaining values are 75, 50, 25 and 0.

Example 2

Input:

100 4 2

Output:

1 50.00
2 25.00
3 12.50
4 6.25

Explanation: The annual rate is 2/4 = 0.5. Successive remaining values are 50, 25, 12.5 and 6.25.

Example 3

Input:

100 4 3

Output:

1 60.00
2 30.00
3 10.00
4 0.00

Explanation: The year weights sum to 10. Deducting 40, 30, 20 and 10 from the initial 100 gives remaining values 60, 30, 10 and 0.