結果

問題 No.1729 ~サンプルはちゃんと見て!~ 16進数と8進数(1)
ユーザー 👑 obakyanobakyan
提出日時 2021-11-13 13:50:25
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 761 bytes
コンパイル時間 204 ms
コンパイル使用メモリ 5,308 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-18 05:54:50
合計ジャッジ時間 1,256 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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, " "))
0