結果

問題 No.792 真理関数をつくろう
ユーザー toshiro_yanagitoshiro_yanagi
提出日時 2019-02-24 17:24:35
言語 Go
(1.22.1)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 695 bytes
コンパイル時間 12,894 ms
コンパイル使用メモリ 222,472 KB
実行使用メモリ 8,300 KB
最終ジャッジ日時 2024-06-02 10:36:39
合計ジャッジ時間 17,559 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 25 ms
7,680 KB
testcase_02 AC 1 ms
5,248 KB
testcase_03 AC 65 ms
7,808 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 65 ms
8,064 KB
testcase_06 AC 674 ms
7,852 KB
testcase_07 AC 10 ms
6,272 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 4 ms
5,376 KB
testcase_16 AC 196 ms
7,400 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 116 ms
5,376 KB
testcase_21 TLE -
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 1 ms
5,376 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