結果
| 問題 |
No.792 真理関数をつくろう
|
| コンテスト | |
| ユーザー |
keymoon
|
| 提出日時 | 2019-02-22 21:47:50 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 46 ms / 2,000 ms |
| コード長 | 1,644 bytes |
| コンパイル時間 | 719 ms |
| コンパイル使用メモリ | 111,092 KB |
| 実行使用メモリ | 29,800 KB |
| 最終ジャッジ日時 | 2024-11-25 07:56:38 |
| 合計ジャッジ時間 | 2,184 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 22 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
class P
{
static void Main()
{
int n = int.Parse(Console.ReadLine());
StringBuilder builder = new StringBuilder();
builder.Append("A=");
bool IsFirst = true;
int max = 1 << n;
bool IsAllTrue = true;
for (int i = 0; i < max; i++)
{
var q = Console.ReadLine().Split().Select(int.Parse).ToList();
if (q.Last() != 1)
{
IsAllTrue = false;
continue;
}
if (!IsFirst) builder.Append("∨");
else IsFirst = false;
builder.Append("(");
for (int j = 0; j < n; j++)
{
if (q[j] == 0) builder.Append("¬");
builder.Append("P_");
builder.Append(j + 1);
if (j != n - 1) builder.Append("∧");
}
builder.Append(")");
}
if (IsFirst) builder.Append("⊥");
if (IsAllTrue) Console.WriteLine("A=⊤");
else Console.WriteLine(builder.ToString());
}
static long Power(long n, long m)
{
const int mod = 1000000007;
long pow = n;
long res = 1;
while (m > 0)
{
if ((m & 1) == 1) res = (res * pow) % mod;
pow = (pow * pow) % mod;
m >>= 1;
}
return res;
}
}
keymoon