結果
| 問題 |
No.792 真理関数をつくろう
|
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2021-02-10 13:33:49 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 224 ms / 2,000 ms |
| コード長 | 1,463 bytes |
| コンパイル時間 | 2,409 ms |
| コンパイル使用メモリ | 77,632 KB |
| 実行使用メモリ | 57,680 KB |
| 最終ジャッジ日時 | 2024-07-08 00:07:45 |
| 合計ジャッジ時間 | 6,612 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 22 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = Integer.parseInt(sc.nextLine());
StringBuilder sb = new StringBuilder();
int trueCount = 0;
int falseCount = 0;
sb.append("A=");
boolean isFirst = true;
for (int i = 0; i < (1 << n); i++) {
char[] line = sc.nextLine().toCharArray();
boolean[] tfs = new boolean[n + 1];
for (int j = 0; j < line.length; j += 2) {
tfs[j / 2] = (line[j] == '1');
}
if (tfs[n]) {
trueCount++;
if (!isFirst) {
sb.append("∨");
}
isFirst = false;
sb.append("(");
for (int j = 0; j < n; j++) {
if (j > 0) {
sb.append("∧");
}
if (!tfs[j]) {
sb.append("¬");
}
sb.append("P_").append(j + 1);
}
sb.append(")");
} else {
falseCount++;
}
}
if (trueCount == (1 << n)) {
System.out.println("A=⊤");
} else if (falseCount == (1 << n)) {
System.out.println("A=⊥");
} else {
System.out.println(sb);
}
}
}
tenten