QOJ.ac

QOJ

Limite de temps : 3 s Limite de mémoire : 512 MB Points totaux : 100

#854. 弓箭手弗拉德

Statistiques

Vlad 站在笛卡尔坐标系的原点 $(0, 0)$。点 $(0, 1)$ 和 $(1, 0)$ 距离 Vlad 恰好 1 米。共有 $N$ 棵树,编号从 $1$ 到 $N$,第 $i$ 棵树由连接点 $(x_i, 0)$ 和 $(x_i, y_i)$ 的垂直线段表示,其中 $x_i$ 和 $y_i$ 为正整数。当 Vlad 以角度 $\alpha$ 射箭时,箭的初始水平速度为 $v_x = C \cdot \cos(\alpha)$,初始垂直速度为 $v_y = C \cdot \sin(\alpha)$。箭不受空气阻力影响,其轨迹为一条包含原点 $(0, 0)$ 的抛物线(具体而言,水平速度 $v_x$ 在整个飞行过程中保持不变,而 $v_y$ 随时间线性减小,每秒减少量为 $g$)。假设重力加速度 $g = 10 \, \text{m/s}^2$。如果箭的轨迹在任何点都不与任何树(更具体地说是代表树的线段)相交,则 Vlad 的目标达成。此外,箭的轨迹必须在 $x$ 坐标大于所有树的 $x$ 坐标的位置与 $x$ 轴相交。

输出一个满足上述条件的 $\tan(\alpha)$ 的可能值。

输入格式

第一行包含一个整数 $z$,表示测试用例的数量。接下来是各测试用例的描述。 每个测试用例的第一行包含一个整数 $1 \le C \le 10^9$,表示 Vlad 箭的速度(单位:米/秒)。 每个测试用例的第二行包含一个整数 $1 \le N \le 100\,000$,表示树的数量。 对于每个测试用例,接下来的 $N$ 行每行包含两个整数 $x_i, y_i$ ($1 \le x_i, y_i \le 10^9$)。第 $i$ 棵树由连接点 $(x_i, 0)$ 和 $(x_i, y_i)$ 的垂直线段表示。 所有测试用例中 $N$ 的总和不超过 $300\,000$。

输出格式

对于每个测试用例,输出一个保留三位小数的数字。该数字必须是 $\tan(\alpha)$ 的正确值之一的近似值,误差不超过 $10^{-3}$。你可以假设解总是存在的,且任何正确的 $\tan(\alpha)$ 值都包含在一个长度至少为 $10^{-2}$ 的解区间内。

样例

输入 1

3
5
1
1 1
5
1
1 1
13
1
7 7

输出 1

2.000
3.000
2.429

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.