結果

問題 No.1097 Remainder Operation
ユーザー yuruhiyayuruhiya
提出日時 2020-06-30 22:19:20
言語 Crystal
(1.11.2)
結果
AC  
実行時間 395 ms / 2,000 ms
コード長 351 bytes
コンパイル時間 18,598 ms
コンパイル使用メモリ 255,796 KB
実行使用メモリ 57,564 KB
最終ジャッジ日時 2023-09-13 10:55:57
合計ジャッジ時間 23,412 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 3 ms
4,632 KB
testcase_03 AC 3 ms
4,496 KB
testcase_04 AC 3 ms
4,580 KB
testcase_05 AC 3 ms
4,484 KB
testcase_06 AC 3 ms
4,616 KB
testcase_07 AC 34 ms
9,852 KB
testcase_08 AC 34 ms
9,852 KB
testcase_09 AC 33 ms
9,928 KB
testcase_10 AC 33 ms
9,856 KB
testcase_11 AC 33 ms
9,876 KB
testcase_12 AC 318 ms
57,408 KB
testcase_13 AC 331 ms
57,500 KB
testcase_14 AC 337 ms
57,564 KB
testcase_15 AC 349 ms
57,404 KB
testcase_16 AC 327 ms
57,404 KB
testcase_17 AC 274 ms
57,496 KB
testcase_18 AC 270 ms
48,160 KB
testcase_19 AC 312 ms
48,088 KB
testcase_20 AC 314 ms
48,204 KB
testcase_21 AC 395 ms
48,128 KB
testcase_22 AC 379 ms
48,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = read_line.to_i
a = read_line.split.map &.to_i64
b = Array.new(40) { [0i64]*n }
b.each_index do |i|
  b[i] = (i == 0 ? a : b[i - 1].map_with_index { |v, j|
    v + b[i - 1][(v + j) % n]
  })
end

read_line.to_i.times do
  k = read_line.to_i64
  puts b.each_with_index.reduce(0i64) { |acc, (v, i)|
    acc + (k.bit(i) == 1 ? v[acc % n] : 0)
  }
end
0