結果

問題 No.2260 Adic Sum
ユーザー simansiman
提出日時 2023-04-09 23:38:49
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,016 ms / 2,000 ms
コード長 208 bytes
コンパイル時間 393 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 61,276 KB
最終ジャッジ日時 2024-04-16 00:03:15
合計ジャッジ時間 11,659 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
12,288 KB
testcase_01 AC 96 ms
12,160 KB
testcase_02 AC 94 ms
12,160 KB
testcase_03 AC 95 ms
12,416 KB
testcase_04 AC 94 ms
12,160 KB
testcase_05 AC 94 ms
12,416 KB
testcase_06 AC 95 ms
12,288 KB
testcase_07 AC 96 ms
12,288 KB
testcase_08 AC 96 ms
12,288 KB
testcase_09 AC 94 ms
12,160 KB
testcase_10 AC 96 ms
12,160 KB
testcase_11 AC 93 ms
12,160 KB
testcase_12 AC 94 ms
12,288 KB
testcase_13 AC 98 ms
12,288 KB
testcase_14 AC 125 ms
17,664 KB
testcase_15 AC 137 ms
19,072 KB
testcase_16 AC 121 ms
16,384 KB
testcase_17 AC 146 ms
19,200 KB
testcase_18 AC 639 ms
42,632 KB
testcase_19 AC 683 ms
42,780 KB
testcase_20 AC 486 ms
31,468 KB
testcase_21 AC 490 ms
31,720 KB
testcase_22 AC 434 ms
31,104 KB
testcase_23 AC 345 ms
30,720 KB
testcase_24 AC 674 ms
39,620 KB
testcase_25 AC 171 ms
23,936 KB
testcase_26 AC 168 ms
24,448 KB
testcase_27 AC 170 ms
24,576 KB
testcase_28 AC 167 ms
24,064 KB
testcase_29 AC 169 ms
23,936 KB
testcase_30 AC 194 ms
21,632 KB
testcase_31 AC 795 ms
24,448 KB
testcase_32 AC 798 ms
26,624 KB
testcase_33 AC 200 ms
25,216 KB
testcase_34 AC 311 ms
29,056 KB
testcase_35 AC 1,016 ms
61,276 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, P = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
m = A.max

x = P
ans = 0

while x <= m
  memo = Hash.new(0)

  A.each do |a|
    ans += memo[a % x]
    memo[a % x] += 1
  end

  x *= P
end

puts ans
0