結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー 👑 obakyan
提出日時 2022-08-16 23:34:33
言語 Lua
(LuaJit 2.1.1734355927)
結果
WA  
実行時間 -
コード長 614 bytes
コンパイル時間 253 ms
コンパイル使用メモリ 6,948 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-03 18:04:17
合計ジャッジ時間 27,302 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

local w, h, x = io.read("*n", "*n", "*n")
if x == 0 then
  for i = 1, h do
    print(string.rep("0", w))
  end
  os.exit()
end
if w % 3 ~= 2 or h % 3 ~= 2 or 36 < x then
  print(-1)
  os.exit()
end
local t = {}
for i = 1, 4 do
  t[i] = math.min(x, 9)
  x = x - t[i]
end
for i = 1, h do
  for j = 1, w do
    if i % 3 == 1 and j % 3 == 1 then
      io.write(t[1])
    elseif i % 3 == 1 and j % 3 == 2 then
      io.write(t[2])
    elseif i % 3 == 2 and j % 3 == 1 then
      io.write(t[3])
    elseif i % 3 == 2 and j % 3 == 2 then
      io.write(t[4])
    else
      io.write(0)
    end
  end
  io.write("\n")
end
0