QOJ.ac

QOJ

Límite de tiempo: 0.2 s Límite de memoria: 1024 MB Puntuación total: 100

#27. 韦诺之战

Estadísticas

你知道《韦诺之战》(The Battle for Wesnoth)吗?这是一款以奇幻为主题的精彩回合制策略游戏。游戏中有精灵、兽人、亡灵、矮人,甚至还有咆哮的龙族!对于本题,你只需要知道每个单位都有一定数量的生命值,在战斗中会减少,并且你需要了解战斗是如何进行的。我们只关注最简单的情况——对一个毫无防备的单位进行普通攻击。这种攻击由三个整数描述:

  • $d$ —— 成功命中一次造成的伤害;
  • $b$ —— 攻击次数;
  • $p$ —— 命中成功的概率(以百分比表示)。

在游戏中,$d$ 和 $b$ 是攻击者的属性,而 $p$ 通常由防御者所处的地形决定。但在本题中,我们假设 $p$ 也是攻击者的属性(就像魔法攻击一样)。例如,考虑一次 $d = 6, b = 2, p = 60$ 的攻击,有三种可能的结果:

  • $16\%$ 的概率,攻击者两次都未命中,不造成任何伤害。
  • $48\%$ 的概率,攻击者命中一次且另一次未命中,造成 $6$ 点伤害。
  • $36\%$ 的概率,攻击者两次都命中,造成总计 $12$ 点伤害。

当防御单位的生命值降至非正数时,该单位死亡。

David 目前正在玩一个扩展包,其中一个特殊单位“精灵公主”拥有非常特殊的魔法攻击:她不再由 $d$ 和 $b$ 描述,而是由一个整数 $m$ 描述。当她攻击时,玩家可以选择任意正整数 $d$ 和 $b$,只要满足 $d \cdot b \le m$。

David 经常需要让他的精灵公主去击杀丑陋的亡灵骷髅或臭气熏天的兽人战士,所以他想知道哪种 $d$ 和 $b$ 的选择能使击杀敌人的概率最高。

题目描述

对于 David 需要击杀的每一个单位,找出 $d$ 和 $b$ 的最佳选择。

输入格式

输入的第一行包含一个整数 $m$ ($1 \le m \le 10^6$) 和一个整数 $p$ ($1 \le p \le 99$) —— 攻击者的参数。第二行包含一个整数 $n$ ($1 \le n \le 10^5$) —— 需要击杀的单位数量。第三行包含 $n$ 个整数 $h_1, h_2, \dots, h_n$ ($1 \le h_i \le 10^6$),其中 $h_i$ 是第 $i$ 个需要击杀的单位的生命值。

输出格式

对于每个需要击杀的单位,输出两个整数:使击杀该单位的概率最大的 $d$ 和 $b$。如果你的输出所对应的概率与最优概率的差不超过 $10^{-6}$,则你的答案将被接受。

子任务

子任务 数据范围 分值
1 $m \le 10$ 10
2 $m \le 100$ 10
3 $m \le 1\,000$ 20
4 $n = 1, m \le 100\,000$ 20
5 $m \le 100\,000$ 25
6 无额外限制 15

说明

计算可以使用 double 类型以保证足够的精度。当然,你必须避免溢出和下溢,以及避免进行不安全的操作,例如将数量级差异巨大的数字相加(例如对于 $a = 0.5$ 和 $b = 10^{-100}$,$a + b$ 的计算结果会被视为 $a$)。

样例

样例输入 1

10 60
3
5 6 7

样例输出 1

5 2
2 5
7 1

说明 1

对应的概率分别为 $84\%$, $68.256\%$, 和 $60\%$。

Warning regarding floating point arithmetic

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.