結果

問題 No.792 真理関数をつくろう
ユーザー tsunabittsunabit
提出日時 2019-07-11 23:37:31
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,125 bytes
コンパイル時間 3,590 ms
コンパイル使用メモリ 75,888 KB
実行使用メモリ 65,124 KB
最終ジャッジ日時 2023-08-08 14:18:20
合計ジャッジ時間 14,771 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 165 ms
57,068 KB
testcase_01 AC 294 ms
61,800 KB
testcase_02 AC 160 ms
59,008 KB
testcase_03 AC 377 ms
62,332 KB
testcase_04 AC 157 ms
57,092 KB
testcase_05 AC 378 ms
62,052 KB
testcase_06 AC 1,237 ms
65,124 KB
testcase_07 AC 247 ms
60,876 KB
testcase_08 AC 160 ms
56,696 KB
testcase_09 AC 166 ms
56,980 KB
testcase_10 AC 168 ms
56,932 KB
testcase_11 AC 159 ms
56,640 KB
testcase_12 AC 168 ms
57,384 KB
testcase_13 AC 157 ms
56,888 KB
testcase_14 AC 158 ms
56,900 KB
testcase_15 AC 208 ms
59,972 KB
testcase_16 AC 589 ms
62,672 KB
testcase_17 AC 204 ms
58,864 KB
testcase_18 AC 157 ms
57,008 KB
testcase_19 AC 156 ms
54,848 KB
testcase_20 AC 413 ms
60,492 KB
testcase_21 TLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import java.math.*;

public class No792 {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	String o = "A=";
    	int[][] q = new int[(int)Math.pow(2, n)][n+1];
    	boolean f0 = false, f1 = false;
    	// ∧∨¬⊥⊤
    	for(int i = 0; i < Math.pow(2, n); i++) {
    		for(int j = 0; j < n + 1; j++) {
    			q[i][j] = sc.nextInt();
    		}
    	}
    	
    	for(int i = 0; i < Math.pow(2, n); i++) {
    			if(q[i][n] == 0) f0 = true;
    			else f1 = true;
    	}
    	if(f0 && !f1) {
    		System.out.println("A=⊥");
    		return;
    	}else if(!f0 && f1) {
    		System.out.println("A=⊤");
    		return;
    	}
    	
    	for(int i = 0; i < Math.pow(2, n); i++) {
    		if(q[i][n] == 1) {
    			o += "(";
    			for(int j = 0; j < n; j++) {
    				if(q[i][j] == 1) o += "P_" + (j+1) + "∧";
    				else o += "¬P_" + (j+1) + "∧";
        		}
    			o += ")";
    		}
    	}
    	o = o.replaceAll("∧\\)\\(", "\\)∨\\(");
    	o = o.replaceAll("∧\\)", "\\)");
    	System.out.println(o);
    }
}
0