結果

問題 No.2260 Adic Sum
ユーザー hir355hir355
提出日時 2023-04-07 21:26:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 511 ms / 2,000 ms
コード長 281 bytes
コンパイル時間 240 ms
コンパイル使用メモリ 82,376 KB
実行使用メモリ 199,508 KB
最終ジャッジ日時 2024-10-06 06:57:23
合計ジャッジ時間 6,887 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
n, p = map(int, input().split())
a = list(map(int, input().split()))
t = 1
ans = 0
while t <= 10 ** 10:
    t *= p
    d = defaultdict(int)
    for x in a:
        d[x % t] += 1
    for v in d.values():
        ans += v * (v - 1) // 2
print(ans)
0