結果

問題 No.1097 Remainder Operation
ユーザー yuruhiyayuruhiya
提出日時 2020-06-30 21:57:56
言語 Crystal
(1.11.2)
結果
AC  
実行時間 391 ms / 2,000 ms
コード長 420 bytes
コンパイル時間 18,129 ms
コンパイル使用メモリ 256,672 KB
実行使用メモリ 57,584 KB
最終ジャッジ日時 2023-09-13 10:55:01
合計ジャッジ時間 24,800 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,488 KB
testcase_01 AC 2 ms
4,400 KB
testcase_02 AC 3 ms
4,544 KB
testcase_03 AC 2 ms
4,516 KB
testcase_04 AC 3 ms
4,452 KB
testcase_05 AC 3 ms
4,608 KB
testcase_06 AC 3 ms
4,536 KB
testcase_07 AC 31 ms
9,740 KB
testcase_08 AC 32 ms
9,740 KB
testcase_09 AC 31 ms
9,812 KB
testcase_10 AC 31 ms
9,992 KB
testcase_11 AC 31 ms
9,740 KB
testcase_12 AC 301 ms
57,384 KB
testcase_13 AC 313 ms
57,532 KB
testcase_14 AC 320 ms
57,464 KB
testcase_15 AC 332 ms
57,584 KB
testcase_16 AC 307 ms
57,384 KB
testcase_17 AC 265 ms
57,460 KB
testcase_18 AC 253 ms
48,256 KB
testcase_19 AC 295 ms
48,196 KB
testcase_20 AC 292 ms
48,100 KB
testcase_21 AC 391 ms
48,152 KB
testcase_22 AC 383 ms
48,148 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.size.times 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
  ans = 0i64
  b.each_with_index do |v, i|
    if k.bit(i) == 1
      ans += v[ans % n]
    end
  end
  puts ans
end
0