程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程解疑 >> string-公式Formula,問題

string-公式Formula,問題

編輯:編程解疑
公式Formula,問題

Description

Nick is a mathematician and his speciality is Boolean logic, especially repetition-free functions. The Boolean function is repetition-free if it can be represented as a repetition-free formula. Formula is repetition-free if each variable occurs in the formula only once.

Let us fix the syntax of considered logical formulae:

Variables — letters from ‘a’ to ‘k’;
Parentheses — if E is a formula, then (E) is another;
Negation — ¬E is a formula for any formula E;
Conjunction — E1 ∧ E2 ∧ ⋯ ∧ En;
Disjunction — E1 ∨ E2 ∨ ⋯ ∨ En.
The operations are listed from the highest priority to the lowest.

The problem is to represent given Boolean function by a repetition-free formula.

Input

The only line of input contains the Boolean function represented as a string consisting of characters ‘a’..‘k’, ‘(’, ‘)’, ‘~’, ‘&’ and ‘|’. The last three tokens stand for ¬, ∧ and ∨ respectively. Tokens can be separated by an arbitrary number of spaces. The line contains 1 000 characters at most. The formula in the file is syntactically correct.

Output

The first line of the output file must contain “Yes” if function is repetition-free and “No” otherwise.

In the former case the following line must contain the repetition-free formula for given Boolean function in the same format as in the input file. The line must contain no more than 1 000 characters.

最佳回答:


http://blog.csdn.net/sr_19930829/article/details/41785767

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved