結果

問題 No.2260 Adic Sum
ユーザー qibqib
提出日時 2023-04-11 13:23:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 776 ms / 2,000 ms
コード長 341 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 216,480 KB
最終ジャッジ日時 2024-04-16 11:54:25
合計ジャッジ時間 7,855 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
54,272 KB
testcase_01 AC 39 ms
54,144 KB
testcase_02 AC 39 ms
53,376 KB
testcase_03 AC 41 ms
53,760 KB
testcase_04 AC 41 ms
53,376 KB
testcase_05 AC 45 ms
54,272 KB
testcase_06 AC 40 ms
53,632 KB
testcase_07 AC 40 ms
54,016 KB
testcase_08 AC 50 ms
64,000 KB
testcase_09 AC 49 ms
62,464 KB
testcase_10 AC 52 ms
64,000 KB
testcase_11 AC 41 ms
54,784 KB
testcase_12 AC 53 ms
65,280 KB
testcase_13 AC 50 ms
63,488 KB
testcase_14 AC 66 ms
79,744 KB
testcase_15 AC 73 ms
87,296 KB
testcase_16 AC 61 ms
76,800 KB
testcase_17 AC 78 ms
89,728 KB
testcase_18 AC 434 ms
166,616 KB
testcase_19 AC 455 ms
173,488 KB
testcase_20 AC 331 ms
141,504 KB
testcase_21 AC 323 ms
141,688 KB
testcase_22 AC 301 ms
144,412 KB
testcase_23 AC 200 ms
114,952 KB
testcase_24 AC 446 ms
160,540 KB
testcase_25 AC 100 ms
102,016 KB
testcase_26 AC 95 ms
102,144 KB
testcase_27 AC 98 ms
101,504 KB
testcase_28 AC 100 ms
102,332 KB
testcase_29 AC 102 ms
101,024 KB
testcase_30 AC 105 ms
91,264 KB
testcase_31 AC 376 ms
92,032 KB
testcase_32 AC 392 ms
91,660 KB
testcase_33 AC 105 ms
93,100 KB
testcase_34 AC 195 ms
139,188 KB
testcase_35 AC 776 ms
216,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

INF = 10 ** 9

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

cnt = [defaultdict(int) for _ in range(31)]
ans = 0
for i in range(n):
  cur = 1
  for j in range(1, 31):
    cur *= p
    if cur > INF:
      break

    ans += cnt[j][a[i] % cur]
    cnt[j][a[i] % cur] += 1

print(ans)
0