QOJ.ac

QOJ

Time Limit: 2.0 s Memory Limit: 1024 MB Total points: 100 Hackable ✓

#9129. 商数和

Statistics

给定一个由 $N$ 个不同的正整数组成的序列 $A = (A_1, A_2, \dots, A_N)$。考虑将 $A$ 中的元素重新排列得到序列 $B = (B_1, B_2, \dots, B_N)$。求以下表达式的最小值:

$$\left\lfloor \frac{B_2}{B_1} \right\rfloor + \left\lfloor \frac{B_3}{B_2} \right\rfloor + \dots + \left\lfloor \frac{B_N}{B_{N-1}} \right\rfloor + \left\lfloor \frac{B_1}{B_N} \right\rfloor$$

其中,$\lfloor x \rfloor$ 表示不超过实数 $x$ 的最大整数。

输入格式

输入通过标准输入按以下格式提供:

$N$ $A_1 \ A_2 \ \dots \ A_N$

数据范围

  • 所有输入均为整数。
  • $2 \le N \le 2 \times 10^5$
  • $1 \le A_i \le 10^{18}$
  • $A_i \neq A_j$ ($i \neq j$)

输出格式

在一行中输出答案。

样例

样例输入 1

3
2 3 6

样例输出 1

3

样例输入 2

2
15 4

样例输出 2

3

样例输入 3

9
284791808 107902 13660981249408 4622332661 13405199 24590921 361 244448137 16077087227955422

样例输出 3

4580

说明

在第一个样例中,如果我们令 $(B_1, B_2, B_3) = (6, 2, 3)$,我们有:

$$\left\lfloor \frac{2}{6} \right\rfloor + \left\lfloor \frac{3}{2} \right\rfloor + \left\lfloor \frac{6}{3} \right\rfloor = 0 + 1 + 2 = 3$$

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.