编程介的小学生 2017-09-07 10:14 采纳率: 20.5%
浏览 683
已采纳

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

x y x|y
0 0 1
0 1 1
1 0 1
1 1 0
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:

Ai is an expression that denotes value of ith bit of number A.
Bi is an expression that denotes value of ith bit of number B.
(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.

Input

The input contains a single integer N (1 <= N <= 100).

Output

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 file shall not exceed 50*N bytes.

This problem contains multiple test cases!

The first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks.

The output format consists of N output blocks. There is a blank line between output blocks.

Sample Input

1

2

Sample Output

((A1|B1)|(((A0|B0)|(A0|B0))|((A1|A1)|(B1|B1))))

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-09-23 00:57
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退
  • ¥20 win系统的PYQT程序生成的数据如何放入云服务器阿里云window版?