問題一覧 > 通常問題

No.1972 Modulo Set

レベル : / AI推定難易度 : 925 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 161
作問者 : magsta / テスター : 👑 Kazun
お気に入りにしたユーザー ProblemId : 6830 / 自分の提出
問題文最終更新日: 2022-06-06 21:59:20
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 347 (順位表) の他の問題:

Problem Statement

You are given $N$ positive integers $A_1,A_2,...,A_N$ and a positive integer $M$.

Let $S$ be the set whose elements are $A_1,A_2...,A_N$.


Among the sets that are subsets of $S$ and satisfy the following condition, find the number of elements of a set with the maximum number of elements.

Condition

Take 2 distinct numbers from the elements of the set, and call them $P, Q$ respectively.

Then, no matter how the numbers are taken, $P+Q$ is never a multiple of $M$.

(If the set has $1$ element, it is considered to always satisfy this condition.)

Constraints

  • $\displaystyle 1 \leq N \leq 10^5$
  • $\displaystyle 1 \leq M \leq 10^{12}$
  • $\displaystyle 1 \leq A_i \leq 10^{12} \ (1 \leq i \leq N)$
  • $\displaystyle A_i \neq A_j \ (1 \leq i,j \leq N, \ i \neq j)$
  • All inputs are integers.

Input

The input is given from standard input in the following format.

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

Output

Output the value you found, followed by a newline.

Sample

Sample 1
Input
4 5
7 14 3 5
Output
3

$\{7, 14, 5\}$ and $\{14, 3, 5\}$ are subsets of the set $S$ that satisfy the condition.

$\{7, 14, 3, 5\}$ does not satisfy the condition, so the maximum number of elements is $3$.

Sample 2
Input
1 8
3
Output
1

If the number of elements is $1$, the condition is always satisfied.

Sample 3
Input
14 5
218 64 142 792 323 402 594 857 394 977 577 495 264 29
Output
12

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。