結果

問題 No.2260 Adic Sum
ユーザー Kiri8128Kiri8128
提出日時 2023-04-07 21:45:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 222 ms / 2,000 ms
コード長 359 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 82,408 KB
実行使用メモリ 137,340 KB
最終ジャッジ日時 2024-04-15 23:50:53
合計ジャッジ時間 4,861 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
55,108 KB
testcase_01 AC 46 ms
54,232 KB
testcase_02 AC 45 ms
53,820 KB
testcase_03 AC 45 ms
55,516 KB
testcase_04 AC 45 ms
54,580 KB
testcase_05 AC 44 ms
53,752 KB
testcase_06 AC 44 ms
53,728 KB
testcase_07 AC 44 ms
54,448 KB
testcase_08 AC 63 ms
67,960 KB
testcase_09 AC 50 ms
61,916 KB
testcase_10 AC 60 ms
66,284 KB
testcase_11 AC 45 ms
54,440 KB
testcase_12 AC 60 ms
65,504 KB
testcase_13 AC 54 ms
64,668 KB
testcase_14 AC 67 ms
78,260 KB
testcase_15 AC 75 ms
85,752 KB
testcase_16 AC 63 ms
76,028 KB
testcase_17 AC 105 ms
96,688 KB
testcase_18 AC 137 ms
88,760 KB
testcase_19 AC 141 ms
89,504 KB
testcase_20 AC 124 ms
86,564 KB
testcase_21 AC 125 ms
86,668 KB
testcase_22 AC 116 ms
86,024 KB
testcase_23 AC 117 ms
92,616 KB
testcase_24 AC 148 ms
94,240 KB
testcase_25 AC 100 ms
97,680 KB
testcase_26 AC 99 ms
96,644 KB
testcase_27 AC 103 ms
97,228 KB
testcase_28 AC 100 ms
97,396 KB
testcase_29 AC 101 ms
97,128 KB
testcase_30 AC 112 ms
89,400 KB
testcase_31 AC 220 ms
137,076 KB
testcase_32 AC 222 ms
137,340 KB
testcase_33 AC 93 ms
87,380 KB
testcase_34 AC 108 ms
85,504 KB
testcase_35 AC 170 ms
92,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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