結果

問題 No.792 真理関数をつくろう
ユーザー tsunabittsunabit
提出日時 2019-07-12 21:47:15
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,004 bytes
コンパイル時間 4,326 ms
コンパイル使用メモリ 78,496 KB
実行使用メモリ 77,464 KB
最終ジャッジ日時 2023-08-12 00:08:09
合計ジャッジ時間 15,284 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 168 ms
61,452 KB
testcase_01 AC 302 ms
60,680 KB
testcase_02 AC 161 ms
56,680 KB
testcase_03 AC 382 ms
60,920 KB
testcase_04 AC 160 ms
56,808 KB
testcase_05 AC 392 ms
62,140 KB
testcase_06 AC 1,273 ms
65,004 KB
testcase_07 AC 257 ms
62,108 KB
testcase_08 AC 160 ms
56,720 KB
testcase_09 AC 166 ms
56,844 KB
testcase_10 AC 168 ms
56,864 KB
testcase_11 AC 164 ms
56,664 KB
testcase_12 AC 173 ms
56,976 KB
testcase_13 AC 159 ms
56,796 KB
testcase_14 AC 159 ms
56,472 KB
testcase_15 AC 227 ms
59,924 KB
testcase_16 AC 613 ms
62,652 KB
testcase_17 AC 219 ms
58,168 KB
testcase_18 AC 163 ms
56,860 KB
testcase_19 AC 160 ms
56,732 KB
testcase_20 AC 421 ms
61,044 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];
    	int c = 0;
    	// ∧∨¬⊥⊤
    	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] == 1) {
    			c++;
    			o += "(";
    			for(int j = 0; j < n; j++) {
    				if(q[i][j] == 1) o += "P_" + (j+1) + "∧";
    				else o += "¬P_" + (j+1) + "∧";
        		}
    			o += ")";
    		}
    	}
    	if(c == 0) {
    		System.out.println("A=⊥");
    	}else if(c == (int)Math.pow(2, n)) {
    		System.out.println("A=⊤");
    	}else {
    		o = o.replaceAll("∧\\)\\(", "\\)∨\\(");
        	o = o.replaceAll("∧\\)", "\\)");
        	System.out.println(o);
    	}
    }
}
0