結果

問題 No.792 真理関数をつくろう
ユーザー 👑 obakyanobakyan
提出日時 2019-03-29 22:24:26
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 769 bytes
コンパイル時間 141 ms
コンパイル使用メモリ 5,504 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 16:47:14
合計ジャッジ時間 1,332 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

v, w, x, y, z = "∧", "∨", "¬", "⊥", "⊤"
n = io.read("*n")
all0, all1 = true, true
tot = math.pow(2, n)
t = {}
for i = 1, tot do
    s = "("
    for j = 1, n do
        if(1 < j) then s = string.format("%s%s", s, v) end
        a = io.read("*n")
        if(a == 0) then
            s = string.format("%s%sP_%d", s, x, j)
        else
            s = string.format("%sP_%d", s, j)
        end
    end
    a = io.read("*n")
    if(a == 1) then all0 = false s = string.format("%s)", s) table.insert(t, s) else all1 = false end
end
io.write("A=")
if(all0) then
    io.write(y)
elseif(all1) then
    io.write(z)
else
    first = true
    for k, v in pairs(t) do
        if(first) then first = false else io.write(w) end
        io.write(v)
    end
end
io.write("\n")
0