結果

問題 No.792 真理関数をつくろう
ユーザー fshutofshuto
提出日時 2019-05-03 13:40:44
言語 Ruby
(3.3.0)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 508 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 11,584 KB
実行使用メモリ 16,848 KB
最終ジャッジ日時 2023-08-30 05:46:07
合計ジャッジ時間 4,341 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,360 KB
testcase_01 AC 85 ms
15,296 KB
testcase_02 AC 80 ms
15,264 KB
testcase_03 AC 88 ms
15,448 KB
testcase_04 AC 83 ms
15,132 KB
testcase_05 AC 89 ms
15,456 KB
testcase_06 AC 119 ms
16,468 KB
testcase_07 AC 83 ms
15,244 KB
testcase_08 AC 78 ms
15,276 KB
testcase_09 AC 80 ms
15,284 KB
testcase_10 AC 78 ms
15,084 KB
testcase_11 AC 80 ms
15,152 KB
testcase_12 AC 82 ms
15,164 KB
testcase_13 AC 79 ms
15,296 KB
testcase_14 AC 79 ms
15,088 KB
testcase_15 AC 82 ms
15,276 KB
testcase_16 AC 95 ms
16,012 KB
testcase_17 AC 83 ms
15,264 KB
testcase_18 AC 81 ms
15,292 KB
testcase_19 AC 80 ms
15,044 KB
testcase_20 AC 100 ms
16,128 KB
testcase_21 AC 132 ms
16,848 KB
testcase_22 AC 80 ms
15,088 KB
testcase_23 AC 79 ms
15,184 KB
testcase_24 AC 79 ms
15,296 KB
testcase_25 AC 79 ms
15,144 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