QOJ.ac

QOJ

時間限制: 1.0 s 記憶體限制: 256 MB 總分: 100 可 Hack ✓

#9660. 库存

统计

Fish 退休了,他回到家乡开了一家商店。

他的店里有 $N$ 种商品在售,第 $i$ 种商品每天正好售出 $x_i$ 件。然而,由于他的库存货架容量固定且有限,为 $V$,他必须管理这些商品的分配。为此,他希望为第 $i$ 种商品分配一个实数值 $v_i$ 作为其在货架上的最大存储量,使得 $\sum v_i = V$。当某种商品售罄时,他可以将该商品补货至其最大存储量。因此,对于第 $i$ 种商品,他每天需要补货 $\frac{x_i}{v_i}$ 次。

请帮助 Fish 确定所有商品的 $v_i$,使得他每天补货所有商品的总次数最少。

输入格式

第一行包含一个整数 $T$,表示测试用例的数量。

对于每个测试用例: 第一行包含两个整数 $N$ 和 $V$。 第二行包含 $N$ 个整数 $x_1, x_2, \dots, x_N$。 同一行中的所有数字均由空格分隔。

输出格式

对于每个测试用例,输出 Case x: y,其中 $x$ 表示从 1 开始的测试用例编号,$y$ 是他每天补货所有商品的最少次数。

如果你的答案与标准答案的绝对误差不超过 $10^{-6}$,则视为正确。

样例

输入格式 1

2
2 2
1 1
2 2
2 8

输出格式 1

Case 1: 2.000000
Case 2: 9.000000

说明

$1 \le T \le 100$ $1 \le N \le 10^5$ $1 \le V \le 10^9$ 对于 90% 的测试用例:$N \le 100$

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.