結果

問題 No.813 ユキちゃんの冒険
ユーザー 👑 obakyanobakyan
提出日時 2019-04-12 22:15:48
言語 Lua
(LuaJit 2.1.1696795921)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 567 bytes
コンパイル時間 202 ms
コンパイル使用メモリ 5,380 KB
実行使用メモリ 8,752 KB
最終ジャッジ日時 2023-08-30 13:26:24
合計ジャッジ時間 4,481 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
7,060 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 8 ms
4,376 KB
testcase_04 AC 15 ms
4,376 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 5 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 6 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = io.read("*n")
p, q = io.read("*n", "*n")

r = {}
l = {}
for i = 0, n+1 do
  r[i] = 0
  l[i] = 0
end
r[1] = 1

rem = 1
genten = 0
migi = 0
sinda = 0
while(0.0001 <= rem) do
  s = {}
  t = {}
  s[0] = 0
  t[0] = 0
  for i = 1, n do
    s[i] = r[i - 1] * q + l[i - 1] * p
    t[i] = l[i + 1] * q + r[i + 1] * p
    sinda = sinda + (r[i] + l[i]) * (1 - p - q)
  end
  s[n+1] = 0
  t[n+1] = 0
  genten = genten + l[1] * q + r[1] * p
  migi = migi + r[n] * q
  rem = 1 - sinda - genten - migi
  for i = 0, n+1 do
    r[i] = s[i]
    l[i] = t[i]
  end
end
print(genten)
0