結果
| 問題 |
No.2260 Adic Sum
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 21:16:50 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 413 ms / 2,000 ms |
| コード長 | 535 bytes |
| コンパイル時間 | 167 ms |
| コンパイル使用メモリ | 82,776 KB |
| 実行使用メモリ | 185,524 KB |
| 最終ジャッジ日時 | 2025-03-20 21:17:40 |
| 合計ジャッジ時間 | 6,198 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 |
ソースコード
n, p = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
max_diff = a[-1] - a[0]
ans = 0
current_power = p
while current_power <= max_diff:
from collections import defaultdict
mod_count = defaultdict(int)
for num in a:
mod = num % current_power
mod_count[mod] += 1
c_k = 0
for cnt in mod_count.values():
c_k += cnt * (cnt - 1) // 2
ans += c_k
next_power = current_power * p
if next_power > max_diff:
break
current_power = next_power
print(ans)
lam6er