結果

問題 No.1376 Simple LPS Problem
ユーザー 👑 obakyanobakyan
提出日時 2022-04-24 21:55:12
言語 Lua
(LuaJit 2.1.1734355927)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 911 bytes
コンパイル時間 188 ms
コンパイル使用メモリ 5,376 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-26 08:46:12
合計ジャッジ時間 2,988 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 60
権限があれば一括ダウンロードができます

ソースコード

diff #

local n, k = io.read("*n", "*n")
if n == 1 then
  print(1)
  os.exit()
elseif n == 2 then
  print(k == 1 and 10 or 11)
  os.exit()
end
if k == 1 then
  print(-1)
  os.exit()
end
if n <= 4 then
  print(string.rep("1", k) .. string.rep("0", n - k))
  os.exit()
end
if k == 2 then
  print(-1)
  os.exit()
end
if n <= 6 then
  print(string.rep("1", k) .. string.rep("0", n - k))
  os.exit()
end
if n == 7 then
  if k == 3 then
    print("0001011")
  else
    print(string.rep("1", k) .. string.rep("0", n - k))
  end
  os.exit()
end
if n == 8 then
  if k == 3 then
    print("00010111")
  else
    print(string.rep("1", k) .. string.rep("0", n - k))
  end
  os.exit()
end
if k == 3 then
  print(-1)
  os.exit()
end
io.write(string.rep("1", k))
local rem = n - k
local v = "010011"
local lp = math.floor(rem / 6)
io.write(string.rep(v, lp))
rem = rem % 6
if 0 < rem then
  io.write(v:sub(1, rem))
end
io.write("\n")
0