結果

問題 No.2260 Adic Sum
ユーザー minimum
提出日時 2023-04-07 21:45:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 372 ms / 2,000 ms
コード長 439 bytes
コンパイル時間 370 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 136,880 KB
最終ジャッジ日時 2024-10-06 07:12:07
合計ジャッジ時間 5,790 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

ans = 0

def slv(ls, P):
    global ans
    dic = dict()
    flag = 0
    for i in ls:
        if i % P not in dic:
            dic[i % P] = []
        dic[i % P].append(i // P)
        if i // P != 0:
            flag = 1
    if flag == 0:
        return
    for i in dic:
        ans += len(dic[i]) * (len(dic[i]) - 1) // 2
        slv(dic[i], P)

N, P = map(int, input().split())
A = list(map(int, input().split()))
slv(A, P)
print(ans)
0