結果

問題 No.1486 ロボット
ユーザー 👑 obakyan
提出日時 2021-04-30 18:55:30
言語 Lua
(LuaJit 2.1.1734355927)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 774 bytes
コンパイル時間 463 ms
コンパイル使用メモリ 5,248 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-18 15:40:52
合計ジャッジ時間 1,196 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

local a, b = io.read("*n", "*n")
local c, d = io.read("*n", "*n")
local e = io.read("*n")
local z1, z2 = 0, 0
local day = 0
local sz = 0
local ret = 0
while true do
  z1, z2 = z1 + 1, z2 + 1
  if a + b < z1 then z1 = 1 end
  if c + d < z2 then z2 = 1 end
  day = day + 1
  if z1 <= a and z2 <= c then
    ret = ret + 1
  end
  if e == day then
    print(ret)
    os.exit()
  end
  if day ~= 1 and z1 == 1 and z2 == 1 then
    sz = day - 1
    ret = ret - 1
    break
  end
end
ret = ret * math.floor(e / sz)
local e = e % sz
day = 0
z1, z2 = 0, 0
while day < e do
  day = day + 1
  z1, z2 = z1 + 1, z2 + 1
  if a + b < z1 then z1 = 1 end
  if c + d < z2 then z2 = 1 end
  if z1 <= a and z2 <= c then
    ret = ret + 1
  end
  if e == day then
    break
  end
end
print(ret)
0