結果

問題 No.1331 Moving Penguin
ユーザー 👑 obakyanobakyan
提出日時 2022-04-15 16:40:07
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 489 ms / 1,500 ms
コード長 809 bytes
コンパイル時間 242 ms
コンパイル使用メモリ 5,376 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 05:22:15
合計ジャッジ時間 14,532 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 269 ms
5,376 KB
testcase_05 AC 268 ms
5,376 KB
testcase_06 AC 268 ms
5,376 KB
testcase_07 AC 273 ms
5,376 KB
testcase_08 AC 274 ms
5,376 KB
testcase_09 AC 271 ms
5,376 KB
testcase_10 AC 273 ms
5,376 KB
testcase_11 AC 270 ms
5,376 KB
testcase_12 AC 269 ms
5,376 KB
testcase_13 AC 266 ms
5,376 KB
testcase_14 AC 276 ms
5,376 KB
testcase_15 AC 272 ms
5,376 KB
testcase_16 AC 270 ms
5,376 KB
testcase_17 AC 270 ms
5,376 KB
testcase_18 AC 269 ms
5,376 KB
testcase_19 AC 268 ms
5,376 KB
testcase_20 AC 264 ms
5,376 KB
testcase_21 AC 274 ms
5,376 KB
testcase_22 AC 269 ms
5,376 KB
testcase_23 AC 264 ms
5,376 KB
testcase_24 AC 267 ms
5,376 KB
testcase_25 AC 269 ms
5,376 KB
testcase_26 AC 274 ms
5,376 KB
testcase_27 AC 276 ms
5,376 KB
testcase_28 AC 285 ms
5,376 KB
testcase_29 AC 279 ms
5,376 KB
testcase_30 AC 95 ms
5,376 KB
testcase_31 AC 160 ms
5,376 KB
testcase_32 AC 83 ms
5,376 KB
testcase_33 AC 125 ms
5,376 KB
testcase_34 AC 190 ms
5,376 KB
testcase_35 AC 371 ms
5,376 KB
testcase_36 AC 379 ms
5,376 KB
testcase_37 AC 379 ms
5,376 KB
testcase_38 AC 99 ms
5,376 KB
testcase_39 AC 266 ms
5,376 KB
testcase_40 AC 139 ms
5,376 KB
testcase_41 AC 306 ms
5,376 KB
testcase_42 AC 469 ms
5,376 KB
testcase_43 AC 473 ms
5,376 KB
testcase_44 AC 470 ms
5,376 KB
testcase_45 AC 489 ms
5,376 KB
testcase_46 AC 474 ms
5,376 KB
testcase_47 AC 474 ms
5,376 KB
testcase_48 AC 263 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local mod = 1000000007
local function badd(x, y) return (x + y) % mod end

local n = io.read("*n")
local a = {}
local t = {}
for i = 1, n do
  a[i] = io.read("*n")
  t[i] = 0
end
local mini = {}
local lim = 300
for i = 1, lim do
  mini[i] = {}
  for j = 1, i do
    mini[i][j] = 0
  end
end
t[n] = 1
for j = 1, lim do
  local pos = (n % j) + 1
  mini[j][pos] = 1
end
for i = n - 1, 1, -1 do
  local ai = a[i]
  local v = 0
  if lim < ai then
    local dst = i + ai
    while dst <= n do
      v = badd(v, t[dst])
      dst = dst + ai
    end
    v = badd(v, t[i + 1])
  else
    local pos = (i % ai) + 1
    v = mini[ai][pos]
    if 1 < ai then
      v = badd(v, t[i + 1])
    end
  end
  t[i] = v
  for j = 1, lim do
    local pos = (i % j) + 1
    mini[j][pos] = badd(mini[j][pos], v)
  end
end
print(t[1])
0