#BS0000374. Cắt dây (Ropes)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Cắt dây (Ropes)
Ropes
Version: Phuoc Hung OJ Extended
PHOJ practice edition. Its constraints, input/output format, examples and judging rules are specified below.
Statement
Given ropes of lengths , cut exactly pieces of the same positive length. A rope may yield several pieces; unused material is discarded. Joining ropes is forbidden. Piece lengths need not be integers. Find the largest possible common length.
Input
The first line contains integers . Each of the next lines contains one integer .
Output
Print the maximum length as a real number. Absolute error must not exceed . The output token may contain at most 128 characters; in scientific notation, the explicit exponent must be from -1000 to 1000.
Subtasks
- Subtask 1 (20 points): ; ; ().
- Subtask 2 (30 points): ; ; ().
- Subtask 3 (50 points): ; ; ().
Illustrative examples (not verified as original samples)
Input
4 11
802
743
457
539
Output
200.500000000
Explanation
At length , the four ropes yield pieces, respectively, totaling 11. Any greater length yields at most 3 pieces from the rope of length 802 and no increase from the other ropes. At most 10 pieces remain possible, proving optimality.
Input
1 3
1
Output
0.333333333
Explanation
The only rope has length 1. Three equal pieces of length use its entire length. Three longer pieces would require more than 1 unit of material.
Input
2 1
7
11
Output
11.000000000
Explanation
Only one piece is needed. The longer of the two ropes has length 11, which can be used intact. Joining ropes is forbidden, so a longer piece is impossible.