CF1845F.Swimmers in the Pool

省选/NOI-

通过率:0%

时间限制:3.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There is a pool of length ll where nn swimmers plan to swim. People start swimming at the same time (at the time moment 00), but you can assume that they take different lanes, so they don't interfere with each other.

Each person swims along the following route: they start at point 00 and swim to point ll with constant speed (which is equal to viv_i units per second for the ii-th swimmer). After reaching the point ll, the swimmer instantly (in negligible time) turns back and starts swimming to the point 00 with the same constant speed. After returning to the point 00, the swimmer starts swimming to the point ll, and so on.

Let's say that some real moment of time is a meeting moment if there are at least two swimmers that are in the same point of the pool at that moment of time (that point may be 00 or ll as well as any other real point inside the pool).

The pool will be open for tt seconds. You have to calculate the number of meeting moments while the pool is open. Since the answer may be very large, print it modulo 109+710^9 + 7.

有一个长度为 ll 的泳池,nn 名游泳者计划在此游泳。所有人同时开始游泳(即在时刻 00 开始),但你可以假设他们使用不同的泳道,因此彼此之间不会相互干扰。

每个人的游泳路线如下:从位置 00 出发,以恒定速度(第 ii 名游泳者的速度为 viv_i 单位/秒)游向位置 ll;到达位置 ll 后,立即(耗时可忽略不计)转身,并以相同的速度返回游向位置 00;回到位置 00 后,再次转向游向位置 ll,如此往复。

我们称某个实数时刻为相遇时刻,当且仅当在该时刻,至少有两名游泳者恰好位于泳池中的同一位置(该位置可以是端点 00 或 ll,也可以是泳池内部任意实数位置)。

泳池开放时长为 tt 秒。你需要计算在泳池开放期间发生的相遇时刻的总数。由于答案可能非常大,请对 109+710^9 + 7 取模后输出。

输入格式

The first line contains two integers ll and tt (1≤l,t≤1091 \le l, t \le 10^9) — the length of the pool and the duration of the process (in seconds).

The second line contains the single integer nn (2≤n≤2⋅1052 \le n \le 2 \cdot 10^5) — the number of swimmers.

The third line contains nn integers v1,v2,…,vnv_1, v_2, \dots, v_n (1≤vi≤2⋅1051 \le v_i \le 2 \cdot 10^5), where viv_i is the speed of the ii-th swimmer. All viv_i are pairwise distinct.

第一行包含两个整数 ll 和 tt(1≤l,t≤1091 \le l, t \le 10^9)—— 分别表示泳池的长度和过程持续时间(单位:秒)。

第二行包含一个整数 nn(2≤n≤2⋅1052 \le n \le 2 \cdot 10^5)—— 表示游泳者的数量。

第三行包含 nn 个整数 v1,v2,…,vnv_1, v_2, \dots, v_n(1≤vi≤2⋅1051 \le v_i \le 2 \cdot 10^5),其中 viv_i 表示第 ii 个游泳者的速度。所有 viv_i 两两互不相同。

输出格式

Print one integer — the number of meeting moments (including moment tt if needed and excluding moment 00), taken modulo 109+710^9 + 7.

输出一个整数——相遇时刻的数量(包括时刻 tt(若需要),但不包括时刻 00),对 109+710^9 + 7 取模。

输入输出样例

  • 输入#1

    9 18
    2
    1 2

    输出#1

    3
  • 输入#2

    12 13
    3
    4 2 6

    输出#2

    10
  • 输入#3

    1 1000000000
    3
    100000 150000 200000

    输出#3

    997200007

说明/提示

In the first example, there are three meeting moments:

  • moment 66, during which both swimmers are in the point 66;
  • moment 1212, during which both swimmers are in the point 66;
  • and moment 1818, during which both swimmers are in the point 00.

在第一个示例中,存在三次相遇时刻:

  • 时刻 66,此时两名游泳者均位于位置 66;
  • 时刻 1212,此时两名游泳者均位于位置 66;
  • 以及时刻 1818,此时两名游泳者均位于位置 00。

输入解题思路,AI测评打分。不知道怎么写?

首页