結果

問題 No.792 真理関数をつくろう
ユーザー toshiro_yanagitoshiro_yanagi
提出日時 2019-02-24 17:24:35
言語 Go
(1.22.1)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 695 bytes
コンパイル時間 10,477 ms
コンパイル使用メモリ 204,452 KB
実行使用メモリ 10,444 KB
最終ジャッジ日時 2023-08-24 21:16:34
合計ジャッジ時間 15,873 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,356 KB
testcase_01 AC 26 ms
8,424 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 69 ms
10,444 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 71 ms
10,424 KB
testcase_06 AC 728 ms
8,332 KB
testcase_07 AC 12 ms
8,208 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,388 KB
testcase_10 AC 1 ms
4,388 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,384 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 5 ms
5,764 KB
testcase_16 AC 209 ms
8,400 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,384 KB
testcase_19 AC 2 ms
4,384 KB
testcase_20 AC 146 ms
5,680 KB
testcase_21 TLE -
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,384 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)

	flg := false
	ans := ""
	for range make([]struct{}, pow(2, n)) {
		q := make([]int8, n)
		for j := range q {
			fmt.Scan(&q[j])
		}
		var r int8
		fmt.Scan(&r)
		if r == 1 {
			if ans != "" {
				ans += "∨"
			}
			ans += "("
			for j, v := range q {
				if j != 0 {
					ans += "∧"
				}
				if v == 0 {
					ans += "¬"
				}
				ans += "P_" + strconv.Itoa(j+1)
			}
			ans += ")"
		} else {
			flg = true
		}
	}
	if ans == "" {
		ans = "⊥"
	} else if !flg {
		ans = "⊤"
	}
	fmt.Printf("A=%s\n", ans)
}

func pow(a, b int) int {
	res := 1
	for range make([]struct{}, b) {
		res *= a
	}
	return res
}
0