結果

問題 No.751 Frac #2
ユーザー 👑 obakyanobakyan
提出日時 2019-04-20 10:32:18
言語 Lua
(LuaJit 2.1.1696795921)
結果
WA  
実行時間 -
コード長 594 bytes
コンパイル時間 195 ms
コンパイル使用メモリ 5,268 KB
実行使用メモリ 4,368 KB
最終ジャッジ日時 2023-10-25 23:47:53
合計ジャッジ時間 2,078 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,368 KB
testcase_01 AC 2 ms
4,368 KB
testcase_02 WA -
testcase_03 AC 1 ms
4,368 KB
testcase_04 AC 1 ms
4,368 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,368 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,368 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1 ms
4,368 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1 ms
4,368 KB
testcase_19 AC 1 ms
4,368 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 2 ms
4,368 KB
testcase_33 AC 2 ms
4,368 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

local n1 = io.read("*n")
local numer, denom = 1, 1
numer = io.read("*n")
for i = 2, n1 do denom = denom * io.read("*n") end
local n2 = io.read("*n")
denom = denom * io.read("*n")
for i = 2, n2 do numer = numer * io.read("*n") end

local minus = false
if(numer * denom < 0) then minus = true end
numer, denom = math.abs(numer), math.abs(denom)
function getgcd(a, b)
  while(0 < a and 0 < b) do
    if(a < b) then b = b % a else a = a % b end
  end
  return math.max(a, b)
end

local gcd = getgcd(numer, denom)
if(minus) then io.write("-") end
io.write(numer / gcd .. " " .. denom / gcd .. "\n")
0