結果
問題 | No.1464 Number Conversion |
ユーザー |
👑 |
提出日時 | 2021-04-11 19:57:10 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 474 bytes |
コンパイル時間 | 87 ms |
コンパイル使用メモリ | 6,684 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-27 14:29:57 |
合計ジャッジ時間 | 1,236 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 29 |
ソースコード
local mfl, mce = math.floor, math.ceil x = io.read() if x:find("%.") then a, b = x:match("(%d+)%.(%d+)") a = tonumber(a) bn = #b b = tonumber(b) denom = 1 for i = 1, bn do denom = denom * 10 end c = a * denom + b while c % 2 == 0 and denom % 2 == 0 do c = mfl(c / 2) denom = mfl(denom / 2) end while c % 5 == 0 and denom % 5 == 0 do c = mfl(c / 5) denom = mfl(denom / 5) end print(c .. "/" .. denom) else print(x .. "/1") end