当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

1747:Expression

题目描述
It is known that Sheffer stroke function (NOT-AND) can be used to construct any Boolean function. The truth table for this function is given below:
Truth table for Sheffer stroke function
xyx|y
001
011
101
110

Consider the problem of adding two binary numbers A and B, each containing N bits. The individual bits of A and B are numbered from 0 (the least significant) to N-1 (the most significant). The sum of A and B can always be represented by N+1 bits. Let's call most significant bit of the sum (bit number N) the overflow bit.

Your task is to construct a logical expression using the Sheffer stroke function that computes the value of the overflow bit for arbitrary values of A and B. Your expression shall be constructed according to the following rules:
  1. Ai is an expression that denotes value of ith bit of number A.
  2. Bi is an expression that denotes value of ith bit of number B.
  3. (x|y) is an expression that denotes the result of Sheffer stroke function for x and y, where x and y are expressions.

When writing the index, i, for bits in A and B, the index shall be written as a decimal number without leading zeros. For example, bit number 12 of A must be written as A12. The expression should be completely parenthesized (according to the 3rd rule). No blanks are allowed inside the expression.
输入解释
The input contains a single integer N (1 <= N <= 100).
输出解释
Write to the output an expression for calculating overflow bit of the addition of two N-bit numbers A and B according to the rules given in the problem statement.
Note: The stroke symbol ( | ) is an ASCII character with code 124 (decimal).

The output size shall not exceed 50*N bytes.
输入样例
2
输出样例
((A1|B1)|(((A0|B0)|(A0|B0))|((A1|A1)|(B1|B1))))

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-1747

最后修改于 2020-10-29T06:13:00+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 10000