結果

問題 No.2260 Adic Sum
ユーザー yabityabit
提出日時 2023-06-28 12:27:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 448 ms / 2,000 ms
コード長 342 bytes
コンパイル時間 591 ms
コンパイル使用メモリ 86,816 KB
実行使用メモリ 200,408 KB
最終ジャッジ日時 2023-09-18 14:41:44
合計ジャッジ時間 8,123 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
71,396 KB
testcase_01 AC 93 ms
71,412 KB
testcase_02 AC 93 ms
71,412 KB
testcase_03 AC 95 ms
71,408 KB
testcase_04 AC 92 ms
71,260 KB
testcase_05 AC 92 ms
71,640 KB
testcase_06 AC 94 ms
71,476 KB
testcase_07 AC 93 ms
71,652 KB
testcase_08 AC 103 ms
77,328 KB
testcase_09 AC 94 ms
71,524 KB
testcase_10 AC 101 ms
77,308 KB
testcase_11 AC 96 ms
71,496 KB
testcase_12 AC 106 ms
77,600 KB
testcase_13 AC 103 ms
77,412 KB
testcase_14 AC 118 ms
86,672 KB
testcase_15 AC 124 ms
92,684 KB
testcase_16 AC 114 ms
84,888 KB
testcase_17 AC 126 ms
95,088 KB
testcase_18 AC 313 ms
154,852 KB
testcase_19 AC 327 ms
153,468 KB
testcase_20 AC 266 ms
160,116 KB
testcase_21 AC 271 ms
160,348 KB
testcase_22 AC 246 ms
146,636 KB
testcase_23 AC 208 ms
110,288 KB
testcase_24 AC 325 ms
139,484 KB
testcase_25 AC 144 ms
106,696 KB
testcase_26 AC 141 ms
103,620 KB
testcase_27 AC 146 ms
106,972 KB
testcase_28 AC 147 ms
106,556 KB
testcase_29 AC 144 ms
106,760 KB
testcase_30 AC 148 ms
100,072 KB
testcase_31 AC 250 ms
96,100 KB
testcase_32 AC 248 ms
96,504 KB
testcase_33 AC 146 ms
106,808 KB
testcase_34 AC 175 ms
105,664 KB
testcase_35 AC 448 ms
200,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt, ceil
from collections import defaultdict
N,P = map(int, input().split())
A = list(map(int, input().split()))
M = max(A)
ans = 0
i = 1
while pow(P, i) <= M:
    D = defaultdict(int)
    p = pow(P, i)
    for j in range(N):
        D[A[j] % p] += 1
    for v in D.values():
        ans += v*(v-1)//2
    i += 1
print(ans)
0