QOJ.ac

QOJ

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

#16872. 水母与 Miku

统计

有 $n+1$ 座城市,编号从 $0$ 到 $n$,由 $n$ 条道路连接。第 $i$ 条道路($1 \le i \le n$)双向连接城市 $i-1$ 和城市 $i$。Jellyfish 在飞回城市 $0$ 后,发现她把 Miku fufu 落在了城市 $n$。

每条道路都有一个正整数的美丽度。记第 $i$ 条道路的美丽度为 $a_i$。

Jellyfish 正在寻找她的 fufu。由于方向感很差,她不知道该往哪个方向走。每天,她都会随机选择一条与当前所在城市相连的道路并穿过它。设 $s$ 为与当前城市相连的所有道路的美丽度之和。对于与当前城市相连的每一条道路,Jellyfish 穿过该道路的概率为 $\frac{x}{s}$,其中 $x$ 是该道路的美丽度,穿过道路后她会到达道路另一端的城市。

Jellyfish 从城市 $0$ 出发,只有当她到达城市 $n$ 时才能找回她的 fufu。

你需要选择各条道路的美丽度,使得 Jellyfish 找回 fufu 所需的期望天数最小。然而,由于资金有限,所有道路的美丽度之和必须小于或等于 $m$。

请计算在最优选择道路美丽度的情况下,Jellyfish 找回 fufu 所需的最小期望天数。

输入格式

输入的第一行包含两个整数 $n$ 和 $m$ ($1 \le n \le m \le 3000$),分别表示道路的数量和道路美丽度之和的最大值。

输出格式

输出在最优选择道路美丽度的情况下,Jellyfish 找回 fufu 所需的最小期望天数。

如果你的答案与标准答案的绝对误差或相对误差不超过 $10^{-9}$,则会被接受。形式化地说,设你的答案为 $a$,标准答案为 $b$,若满足 $\frac{|a-b|}{\max(1, |b|)} \le 10^{-9}$,则你的答案被视为正确。

样例

输入格式 1

3 8

输出格式 1

5.200000000000

输入格式 2

10 98

输出格式 2

37.721155173329

说明

在第一个样例中,最优的美丽度分配为 $a = [1, 2, 5]$。Jellyfish 找回 fufu 所需的期望天数为 $5.2$。

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.