結果

問題 No.792 真理関数をつくろう
ユーザー michonz4michonz4
提出日時 2020-01-11 16:22:12
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 811 bytes
コンパイル時間 1,082 ms
コンパイル使用メモリ 30,168 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-16 13:04:09
合計ジャッジ時間 2,831 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <math.h>

int main() {
  int n, a=0;
  scanf("%d", &n);

  int nn=pow(2, n);
  int arr[nn][n+1];
  for (int i=0; i<nn; i++) {
    for (int j=0; j<n+1; j++) {
      scanf("%d", &arr[i][j]);
      if (arr[i][n]==1) a++;    
    }
  }

  printf("A=");
  if (a==nn) {
    printf("⊤\n");
  } else if (a==0) {
    printf("⊥\n");
  } else {
    for (int i=0; i<nn; i++) {
      if (arr[i][n]==1) {
        printf("(");
        
        for (int j=0; j<n; j++) {
          if (arr[i][j]==1) {
            printf("P_%d", j+1);
          } else {
            printf("¬P_%d", j+1);
          }
          if (j<n-1) {
            printf("∧");
          }
        }

        printf(")");
        if (a>1) {
          printf("∨");
          a--;
        }
      }
    }
  }

  return 0;
}
0