PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000377. Tỷ suất hoàn vốn nội bộ (Internal Rate of Return)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tỷ suất hoàn vốn nội bộ (Internal Rate of Return)
Internal Rate of Return
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
An investment has an initial cash flow followed by positive cash flows at the ends of subsequent periods. An internal rate of return is a value for which the net present value is zero:
Determine the valid rates. A rate may be negative.
Input
The first line contains integer . The second line contains integers .
Output
If there is exactly one rate, print it rounded to exactly two decimal places (ties away from zero). If none exists, print No; if multiple exist, print Too many. A rounded zero is printed as 0.00.
Subtasks
- Subtask 1 (20 points): ; ; for every .
- Subtask 2 (30 points): ; ; for every .
- Subtask 3 (50 points): ; ; for every .
Examples
Input
1
-1 2
Output
1.00
Explanation
From , we get and .
Input
2
-8 6 9
Output
0.50
Explanation
Let . The roots of are and ; only is positive. Thus .