結果

問題 No.792 真理関数をつくろう
ユーザー toshiro_yanagitoshiro_yanagi
提出日時 2019-02-24 20:05:20
言語 Go
(1.22.1)
結果
TLE  
実行時間 -
コード長 748 bytes
コンパイル時間 13,937 ms
コンパイル使用メモリ 208,504 KB
実行使用メモリ 12,812 KB
最終ジャッジ日時 2023-08-25 02:55:49
合計ジャッジ時間 18,163 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 28 ms
10,448 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 78 ms
8,392 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 81 ms
10,428 KB
testcase_06 AC 934 ms
8,400 KB
testcase_07 AC 12 ms
8,276 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 5 ms
5,780 KB
testcase_16 AC 253 ms
8,416 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 127 ms
5,680 KB
testcase_21 TLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"fmt"
)

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_"
				k := j + 1
				if k >= 10 {
					ans += "1"
				}
				ans += string('0' + k%10)
			}
			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