結果

問題 No.2260 Adic Sum
ユーザー ntudantuda
提出日時 2023-04-07 23:33:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 488 ms / 2,000 ms
コード長 325 bytes
コンパイル時間 248 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 178,960 KB
最終ジャッジ日時 2024-04-15 23:57:53
合計ジャッジ時間 5,997 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
53,248 KB
testcase_01 AC 49 ms
53,504 KB
testcase_02 AC 45 ms
53,376 KB
testcase_03 AC 45 ms
53,632 KB
testcase_04 AC 46 ms
53,632 KB
testcase_05 AC 45 ms
53,504 KB
testcase_06 AC 47 ms
53,888 KB
testcase_07 AC 45 ms
53,504 KB
testcase_08 AC 54 ms
61,952 KB
testcase_09 AC 48 ms
54,144 KB
testcase_10 AC 54 ms
61,184 KB
testcase_11 AC 46 ms
53,632 KB
testcase_12 AC 60 ms
63,872 KB
testcase_13 AC 56 ms
62,592 KB
testcase_14 AC 75 ms
77,824 KB
testcase_15 AC 84 ms
85,248 KB
testcase_16 AC 70 ms
75,264 KB
testcase_17 AC 89 ms
88,576 KB
testcase_18 AC 309 ms
157,452 KB
testcase_19 AC 329 ms
164,032 KB
testcase_20 AC 247 ms
142,728 KB
testcase_21 AC 250 ms
142,484 KB
testcase_22 AC 224 ms
145,032 KB
testcase_23 AC 178 ms
114,868 KB
testcase_24 AC 326 ms
162,188 KB
testcase_25 AC 103 ms
102,656 KB
testcase_26 AC 101 ms
99,200 KB
testcase_27 AC 105 ms
103,040 KB
testcase_28 AC 103 ms
102,272 KB
testcase_29 AC 104 ms
102,656 KB
testcase_30 AC 116 ms
91,136 KB
testcase_31 AC 217 ms
91,264 KB
testcase_32 AC 225 ms
91,008 KB
testcase_33 AC 111 ms
92,712 KB
testcase_34 AC 147 ms
109,364 KB
testcase_35 AC 488 ms
178,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

N, P = map(int, input().split())
A = list(map(int, input().split()))
P2 = P
maxa = max(A)
ans = 0
while P2 <= maxa:
    dic = defaultdict(int)
    for a in A:
        dic[a % P2] += 1
    for v in dic.values():
        if v > 1:
            ans += v * (v - 1) // 2
    P2 *= P
print(ans)
0