結果

問題 No.792 真理関数をつくろう
ユーザー Konton7Konton7
提出日時 2020-04-27 18:34:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 644 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 13,440 KB
最終ジャッジ日時 2024-05-01 20:20:17
合計ジャッジ時間 2,131 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,624 KB
testcase_01 AC 35 ms
10,752 KB
testcase_02 AC 30 ms
10,752 KB
testcase_03 AC 38 ms
11,136 KB
testcase_04 AC 29 ms
10,624 KB
testcase_05 AC 39 ms
11,136 KB
testcase_06 AC 68 ms
12,416 KB
testcase_07 AC 30 ms
10,624 KB
testcase_08 AC 27 ms
10,752 KB
testcase_09 AC 29 ms
10,624 KB
testcase_10 AC 29 ms
10,624 KB
testcase_11 AC 29 ms
10,624 KB
testcase_12 AC 29 ms
10,752 KB
testcase_13 AC 31 ms
10,624 KB
testcase_14 AC 30 ms
10,624 KB
testcase_15 AC 29 ms
10,624 KB
testcase_16 AC 46 ms
11,648 KB
testcase_17 AC 30 ms
10,752 KB
testcase_18 AC 28 ms
10,752 KB
testcase_19 AC 29 ms
10,752 KB
testcase_20 AC 56 ms
11,392 KB
testcase_21 AC 83 ms
13,440 KB
testcase_22 AC 30 ms
10,752 KB
testcase_23 AC 29 ms
10,752 KB
testcase_24 AC 29 ms
10,624 KB
testcase_25 AC 30 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())

table =[ [ int(v) for v in input().split() ] for i in range(2**n)] 

r = [table[i][-1] for i in range(2**n)]

if all(r):
    print("A=⊤")
    
elif not any(r):
    print("A=⊥")

else:
    trueexpr = []
    for i in range(2**n):
        if r[i]:
            s = []
            for j in range(n):
                if table[i][j] == 1:
                    s.append("P_" + str(j + 1))
                else:
                    s.append("¬P_" + str(j + 1))
            s = "∧".join(s)
            trueexpr.append("(" + s + ")")
    trueexpr = "∨".join(trueexpr)
    print("A=" + trueexpr)
                    
            
0