結果

問題 No.1097 Remainder Operation
ユーザー yuruhiyayuruhiya
提出日時 2020-06-30 22:01:16
言語 Crystal
(1.11.2)
結果
AC  
実行時間 425 ms / 2,000 ms
コード長 408 bytes
コンパイル時間 17,978 ms
コンパイル使用メモリ 255,340 KB
実行使用メモリ 57,504 KB
最終ジャッジ日時 2023-09-13 10:55:30
合計ジャッジ時間 24,082 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,552 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 3 ms
4,532 KB
testcase_03 AC 3 ms
4,564 KB
testcase_04 AC 3 ms
4,392 KB
testcase_05 AC 3 ms
4,536 KB
testcase_06 AC 3 ms
4,448 KB
testcase_07 AC 33 ms
9,820 KB
testcase_08 AC 34 ms
9,940 KB
testcase_09 AC 34 ms
9,856 KB
testcase_10 AC 34 ms
9,752 KB
testcase_11 AC 33 ms
9,984 KB
testcase_12 AC 321 ms
57,440 KB
testcase_13 AC 339 ms
57,468 KB
testcase_14 AC 355 ms
57,444 KB
testcase_15 AC 377 ms
57,416 KB
testcase_16 AC 331 ms
57,316 KB
testcase_17 AC 279 ms
57,504 KB
testcase_18 AC 267 ms
48,236 KB
testcase_19 AC 324 ms
48,164 KB
testcase_20 AC 327 ms
48,064 KB
testcase_21 AC 425 ms
48,148 KB
testcase_22 AC 423 ms
48,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = read_line.to_i
a = read_line.split.map &.to_i64
b = Array.new(Math.log2(10i64**12).to_i.succ) { [0i64]*n }
b.each_index do |i|
  if i == 0
    b[i] = a
  else
    b[i] = b[i - 1].map_with_index { |v, j|
      v + b[i - 1][(v + j) % n]
    }
  end
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