結果
問題 |
No.1729 ~サンプルはちゃんと見て!~ 16進数と8進数(1)
|
ユーザー |
👑 |
提出日時 | 2021-11-13 13:50:25 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 761 bytes |
コンパイル時間 | 242 ms |
コンパイル使用メモリ | 6,820 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-27 09:08:08 |
合計ジャッジ時間 | 925 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 |
ソースコード
local s = io.read() local t = {} local f = {"1010", "1011", "1100", "1101", "1110", "1111"} local n = #s for i = 1, n do local v = s:byte(i) - 64 table.insert(t, f[v]) end s = table.concat(t) n = #s f = {"000", "001", "010", "011", "100", "101", "110", "111"} local g = {} for i = 1, 8 do g[i] = 0 end for i = n, 1, -3 do local left = math.max(1, i - 2) local v = s:sub(left, i) if #v == 1 then v = "0" .. v end if #v == 2 then v = "0" .. v end for j = 1, 8 do if f[j] == v then g[j] = g[j] + 1 break end end end local ret = {} for i = 1, 8 do local f = true for j = 1, 8 do if g[i] < g[j] then f = false end end if f then table.insert(ret, i - 1) end end -- print(table.concat(g, " ")) print(table.concat(ret, " "))