問題一覧 > 通常問題

No.2260 Adic Sum

レベル : / AI推定難易度 : 1000 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 166
作問者 : karinohito / テスター : sotanishy
お気に入りにしたユーザー ProblemId : 9346 / 自分の提出
問題文最終更新日: 2023-04-07 21:18:03
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 383 (順位表) の他の問題:

Problem Statement

For a positive integer $n$, let $v_p(n)$ denote the number of times $n$ is divisible by a prime $p$.
More precisely, for a positive integer $n$, there uniquely exists a pair of a non-negative integer $k$ and an integer $m$ with $m\not\equiv 0\mod{p}$ such that $n=p^km$, and we define $v_p(n)=k$.

You are given a prime $P$ and a sequence of positive integers $A=(A_1,A_2,\dots,A_N)$ of length $N$ whose values are all distinct.
Find $$\sum_{i=1}^{N-1}\sum_{j=i+1}^{N}v_P(|A_i-A_j|)$$
.

Input

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

  • $2 \leq N \leq 10^5$
  • $2 \leq P \le 10^9$
  • $P$ is a prime
  • $1 \leq A_i \le 10^9$
  • $A_i\neq A_j$ if $i\neq j$
  • All input values are integers

Output

Print a newline at the end.

Sample

Sample 1
Input
3 2
1 3 5
Output
4

We have $v_P(|1-3|)=1$, $v_P(|1-5|)=2$, $v_P(|3-5|)=1$.
Therefore, print $1+2+1=4$.

Sample 2
Input
5 5
5 55 555 5555 55555
Output
30

Sample 3
Input
8 3
7023 2800 6599 9703 543 4221 1307 6572
Output
18

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