結果

問題 No.2260 Adic Sum
コンテスト
ユーザー Kiri8128
提出日時 2023-04-07 21:45:49
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 143 ms / 2,000 ms
コード長 359 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 182 ms
コンパイル使用メモリ 84,992 KB
実行使用メモリ 145,408 KB
最終ジャッジ日時 2026-04-22 03:38:31
合計ジャッジ時間 3,873 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import defaultdict
def calc(L):
    ret = 0
    D = defaultdict(list)
    for a in L:
        D[a % P].append(a // P)
    for k, v in D.items():
        l = len(v)
        ret += l * (l - 1) // 2
        if l > 1:
            ret += calc(v)
    return ret

N, P = map(int, input().split())
A = [int(a) for a in input().split()]
print(calc(A))
0