結果

問題 No.792 真理関数をつくろう
ユーザー ohreitetsuohreitetsu
提出日時 2019-03-08 22:14:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 929 bytes
コンパイル時間 699 ms
コンパイル使用メモリ 79,784 KB
実行使用メモリ 4,672 KB
最終ジャッジ日時 2023-09-05 19:45:19
合計ジャッジ時間 1,767 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <string.h>
#include <math.h>
using namespace std;

int main(int argc, char* argv[])
{
	int N;
	int C;
	cin>>N;
	C=(int)pow(2.0,N);
	vector<vector<int>> Q(C,vector<int>(N));
	vector<int> R(C);
	int i,j;
	for (i=0;i<C;i++){
		for (j=0;j<N;j++){
			cin>>Q[i][j];
		}
		cin>>R[i];
	}
	int rSum=0;
	for (i=0;i<C;i++){
		rSum+=R[i];
	}
	cout<<"A=";
	if (rSum==C){
		cout<<"⊤"<<endl;
		return 0;
	}else if (rSum==0){
		cout<<"⊥"<<endl;
		return 0;
	}
	vector<string> S;
	for (i=0;i<C;i++){
		if (R[i]==1){
			string s;
			for (j=0;j<N;j++){
				if (Q[i][j]==1){
					s+="P_";
				}else{
					s+="¬P_";
				}
				char Num[10];
				sprintf(Num,"%d",j+1);
				s+=Num;
				if (j<N-1){
					s+="∧";
				}
			}
			S.push_back(s);
		}
	}
	for (i=0;i<S.size();i++){
		if (i>0){
			cout<<"∨";
		}
		cout<<"(";
		cout<<S[i];
		cout<<")";
	}
	return 0;
}
0