結果

問題 No.792 真理関数をつくろう
ユーザー betrue12betrue12
提出日時 2019-02-22 22:30:57
言語 Ruby
(3.3.0)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 508 bytes
コンパイル時間 123 ms
コンパイル使用メモリ 11,272 KB
実行使用メモリ 17,004 KB
最終ジャッジ日時 2023-08-16 19:54:48
合計ジャッジ時間 3,243 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
15,052 KB
testcase_01 AC 71 ms
15,224 KB
testcase_02 AC 69 ms
15,120 KB
testcase_03 AC 73 ms
15,380 KB
testcase_04 AC 67 ms
15,140 KB
testcase_05 AC 74 ms
15,476 KB
testcase_06 AC 106 ms
16,472 KB
testcase_07 AC 70 ms
15,256 KB
testcase_08 AC 67 ms
15,064 KB
testcase_09 AC 69 ms
15,060 KB
testcase_10 AC 68 ms
15,240 KB
testcase_11 AC 67 ms
15,056 KB
testcase_12 AC 69 ms
15,256 KB
testcase_13 AC 69 ms
15,316 KB
testcase_14 AC 67 ms
15,236 KB
testcase_15 AC 71 ms
15,008 KB
testcase_16 AC 86 ms
15,972 KB
testcase_17 AC 69 ms
15,272 KB
testcase_18 AC 67 ms
15,064 KB
testcase_19 AC 69 ms
15,132 KB
testcase_20 AC 87 ms
15,880 KB
testcase_21 AC 115 ms
17,004 KB
testcase_22 AC 71 ms
15,056 KB
testcase_23 AC 68 ms
15,144 KB
testcase_24 AC 67 ms
15,240 KB
testcase_25 AC 68 ms
15,056 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
q = Array.new(1<<N){[]}
a = []
(1<<N).times do |i|
    q[i] = gets.split.map(&:to_i)
    a[i] = q[i].pop
end

print "A="
if a.uniq.size == 1
    puts a[0] == 1 ? "⊤" : "⊥"
else
    ans = []
    (1<<N).times do |i|
        if a[i] == 1
            arr = []
            N.times do |k|
                str = (q[i][k] == 1 ? "" : "¬") + "P_#{k+1}"
                arr.push(str)
            end
            ans.push("(" + arr.join("∧") + ")")
        end
    end
    puts ans.join("∨")
end
0