QOJ.ac

QOJ

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

#3659. 整数除法

Estadísticas

在 C++ 中,正整数除法总是向下取整。因此,有时两个不同的整数在除以同一个除数后会变得相等。例如在 C++ 中,$5/4$ 和 $7/4$ 都等于 $1$,但 $5 \neq 7$。

给定一个非负整数列表和一个除数,请问列表中有多少对不同的元素,在 C++ 中除以该除数后结果相同?

输入格式

第一行包含两个整数 $n$ ($1 \le n \le 200\,000$),表示列表中元素的个数,以及 $d$ ($1 \le d \le 10^9$),表示除数。

第二行包含 $n$ 个整数 $a_1, \dots, a_n$ ($0 \le a_i \le 10^9$),其中 $a_i$ 是列表中的第 $i$ 个元素。

输出格式

输出一个整数,表示满足 $1 \le i < j \le n$ 且在 C++ 中进行整数除法时满足 $a_i/d = a_j/d$ 的不同下标对 $(i, j)$ 的数量。注意,列表中的数字不一定各不相同(即可能存在 $i \neq j$ 使得 $a_i = a_j$)。

样例

样例输入 1

5 4
4 5 6 7 8

样例输出 1

6

样例输入 2

5 1
4 5 6 7 8

样例输出 2

0

样例输入 3

6 1
1 2 1 2 1 2

样例输出 3

6

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.