問題一覧 > 通常問題

No.68 A Common Stick-Cutting Problem (2)

レベル : / AI推定難易度 : 1300 / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 小数誤差許容問題 絶対誤差または相対誤差が $10^{-9}$ 以下。ただし、ジャッジ側の都合で500桁未満にしてください
タグ : (AC するまで非表示) / 解いたユーザー数 110
作問者 : LayCurse
お気に入りにしたユーザー ProblemId : 146 / 自分の提出
問題文最終更新日: 2026-06-27 14:04:41
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 53 (順位表) の他の問題:

Problem Statement

Yuki has \(N\) sticks, and the length of the \(i\)-th stick is \(L_i\).
The sticks can be cut freely (in the direction that divides their length), but they cannot be joined together.
Yuki wants to make sticks of the same length, and is curious about how long they can be for a given number of sticks.
Write a program that, for making \(K_1, K_2,\ldots,K_Q\) sticks of the same length, finds the maximum possible length of the sticks in each case.

Input

\(N\)
\(L_1\ L_2\ \cdots\ L_N\)
\(Q\)
\(K_1\ K_2\ \cdots\ K_Q \)

\(1 \leq N \leq 100000 = 10^5\)
\(1 \leq L_i \leq 1000000000 = 10^9\)
\(1 \leq Q \leq 100000 = 10^5\)
\(1 \leq K_i \leq 500000 = 5 \times 10^5\)

Output

On the $i$-th line, output the maximum length achievable when making $K_i$ sticks of the same length.
Your answer is considered correct if the absolute error or the relative error is at most $10^{-9}$.

Sample

Sample 1
Input
2
10 20
2
3 4
Output
10.00
6.666666666666667

By cutting the stick of length \(20\) into exactly \(2\) equal parts, you get \(3\) sticks of length \(10\).
Also, by cutting the stick of length \(20\) into \(3\) equal parts, and cutting the stick of length \(10\) so that only a length of \(20/3\) remains and discarding the rest, you get \(4\) sticks of length \(20/3\).

Sample 2
Input
5
99 88 77 66 55
5
1 10 100 1000 100000
Output
99
33
3.807692307692307
0.384279475982533
0.003849923001540

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。