結果
| 問題 |
No.792 真理関数をつくろう
|
| コンテスト | |
| ユーザー |
pengin_2000
|
| 提出日時 | 2020-02-20 18:14:15 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 10 ms / 2,000 ms |
| コード長 | 812 bytes |
| コンパイル時間 | 410 ms |
| コンパイル使用メモリ | 30,336 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-08 19:07:06 |
| 合計ジャッジ時間 | 1,557 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 22 |
ソースコード
#include<stdio.h>
int main()
{
int n;
scanf("%d", &n);
int i, j;
int m = 1;
for (i = 0; i < n; i++)
m *= 2;
int q[5003][20], r[5003];
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
scanf("%d", &q[i][j]);
scanf("%d", &r[i]);
}
int c[2];
c[0] = c[1] = 0;
for (i = 0; i < m; i++)
c[r[i]]++;
if (c[0] == 0)
{
printf("A=⊤\n");
return 0;
}
if (c[1] == 0)
{
printf("A=⊥\n");
return 0;
}
printf("A=");
for (i = 0; i < m; i++)
{
if (r[i] > 0)
{
printf("(");
for (j = 0; j < n - 1; j++)
{
if (q[i][j] > 0)
printf("P_%d∧", j + 1);
else
printf("¬P_%d∧", j + 1);
}
if (q[i][n - 1] > 0)
printf("P_%d)", n);
else
printf("¬P_%d)", n);
if (c[1] > 1)
printf("∨");
else
printf("\n");
c[1]--;
}
}
return 0;
}
pengin_2000