結果

問題 No.792 真理関数をつくろう
ユーザー potoooooooo
提出日時 2019-02-23 13:22:02
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 704 bytes
コンパイル時間 1,729 ms
コンパイル使用メモリ 170,280 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-29 16:28:52
合計ジャッジ時間 2,715 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n; cin >> n;
    string s = "A=";
    int cnt = 0;
    for (int j = 0; j < (1 << n); j++) {
        string tmp = "";
        for (int i = 0; i < n; i++) {
            if (i > 0) tmp += "∧";
            int x; cin >> x;
            if (x == 0) tmp += "¬";
            tmp += "P_" + to_string(i+1);
        }
        int r; cin >> r;
        if (r == 1) {
            if (cnt > 0) {
                s += "∨";
            }
            s += "(" + tmp + ")";
            cnt++;
        }
    }
    if (cnt == 0) cout << "A=⊥" << endl;
    else if (cnt == (1 << n)) cout << "A=⊤" << endl;
    else cout << s << endl;
    return 0;
}
0