結果

問題 No.2260 Adic Sum
ユーザー lloyzlloyz
提出日時 2023-04-07 23:23:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 519 ms / 2,000 ms
コード長 286 bytes
コンパイル時間 233 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 179,204 KB
最終ジャッジ日時 2024-04-15 23:58:08
合計ジャッジ時間 6,447 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
53,248 KB
testcase_01 AC 44 ms
53,632 KB
testcase_02 AC 45 ms
53,376 KB
testcase_03 AC 45 ms
53,376 KB
testcase_04 AC 45 ms
53,632 KB
testcase_05 AC 44 ms
53,888 KB
testcase_06 AC 45 ms
53,632 KB
testcase_07 AC 45 ms
53,504 KB
testcase_08 AC 57 ms
62,336 KB
testcase_09 AC 48 ms
59,008 KB
testcase_10 AC 52 ms
61,472 KB
testcase_11 AC 45 ms
53,760 KB
testcase_12 AC 58 ms
64,128 KB
testcase_13 AC 54 ms
62,592 KB
testcase_14 AC 76 ms
78,464 KB
testcase_15 AC 80 ms
86,016 KB
testcase_16 AC 66 ms
74,880 KB
testcase_17 AC 83 ms
88,192 KB
testcase_18 AC 323 ms
157,512 KB
testcase_19 AC 350 ms
164,160 KB
testcase_20 AC 248 ms
142,884 KB
testcase_21 AC 256 ms
142,628 KB
testcase_22 AC 230 ms
144,668 KB
testcase_23 AC 179 ms
114,748 KB
testcase_24 AC 342 ms
162,500 KB
testcase_25 AC 102 ms
103,168 KB
testcase_26 AC 96 ms
99,584 KB
testcase_27 AC 100 ms
103,520 KB
testcase_28 AC 99 ms
102,912 KB
testcase_29 AC 100 ms
103,040 KB
testcase_30 AC 109 ms
91,008 KB
testcase_31 AC 288 ms
90,880 KB
testcase_32 AC 289 ms
91,084 KB
testcase_33 AC 108 ms
92,672 KB
testcase_34 AC 153 ms
109,604 KB
testcase_35 AC 519 ms
179,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

n, p = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
pow_p = p
while pow_p < max(A) + 10:
    M = defaultdict(int)
    for i in range(n):
        ans += M[A[i] % pow_p]
        M[A[i] % pow_p] += 1
    pow_p *= p
print(ans)
0