2 shunfurh shunfurh 于 2017.09.07 18:14 提问

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个回答

caozhy
caozhy   Ds   Rxr 2017.09.23 08:57
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
Expression Studio Ultimate4的密钥
Expression Studio软件套装包括Expression Web,Expression Blend, Expression Design, Expression Media 和 Expression Encoder
使用Expression动态构造一个条件表达式
设有对象: class Student {       pubic string Name{get;set;} } 查询时,使用t=>t.Name=="jim";但如果条件参数不是固定的,需要动态构造,则不能在代码中这样硬编码了,需要使用Expression动态创建。如下所示: Expression> Build(Student student)  {             va
CSS Expression用法总结
CSS Expression用法总结 转自http://www.chencheng.org/demo/css-expression.phpCSS Expression,动态 CSS 属性,IE 私有,自 5.0 开始引入(IE8 将不再支持),参考 MSDN,不过有时用javascript动态生成它作为IE6的hack还是不错的!这东西的优点:使 CSS 属性动态生成,所以基本
AOP expression语法
在使用AOP时,指定一个pointcut的同时会定义一个expression,来表示对什么方法使用AOP。 类似expression="execution(public * com.baidu.map.*Ctr.*Handle(..))"等 语法为:execution(修饰符  返回值  包名.类名/接口名.方法名(参数列表)) 其中: 1、返回类型、方法名、参数是必须有的. 2、*表示
使用CSS Expression解决某些浏览器兼容问题
<br />虽然无奈,但是不想一有什么就去写JS,冲突也会是个头痛的问题,所以这个Expression还是挺有用的,在CSS代码后插入expression语句,自定义控制属性,只被IE识别的方法,通常针对IE6及其一下的版本居多,IE7对CSS的支持已经有了很大改进,会用到的情况比较少,IE8已宣布在其标准模式下不再支持这一语句,呵呵,多好啊,以后为不同版本的IE还要多写几份HACK,咱们不怕没工作做了哩~~无奈到想哭。。。<br />1. min-width/max-width 控制容器最小宽度或图片最大
关于CSS中expression
在网上第一次注意到css里有expression这个属性,于是搜索了一下,得到了一下相关知识贴出来也许对大家有所帮助,感谢原作者的劳动。CSS中expression使用简介作者:dozb定义IE5及其以后版本支持在CSS中使用expression,用来把CSS属性和Javascript表达式关联起来,这里的CSS属性可以是元素固有的属性,也可以是自定义属性。就是说CSS属性后面可以是一段Javas
Expression: (stream!=NULL)
近段时间用VC编程序,代码运行正确,但总是到最后的时候弹出如下错误提示: Debug Assertion Failed! Program:... File:fclose.c Expression: (stream!=NULL) 上网查了很多资料,尝试了一个星期,最后加断点,才定位到错误的位置。 如错误提示所说:是因为关闭文件指针(fclose(f))
『已解决』expected expression before ‘struct’
<br /><br />编译一个应用程序,报以下错误:<br />[root@localhost 3250RTC]# make<br />gcc -o 3250rtc 3250rtc.c<br />3250rtc.c: In function ‘update_rtc’:<br />3250rtc.c:47: error: expected expression before ‘struct’<br />make: *** [3250rtc] Error 1<br /> <br />解决办法:<br />#i
struts2标签使用时产生异常:freemarker.core.InvalidReferenceException: Expression parameters.id is undefined
Expression parameters.id is undefined on line 36, column 60 in template/simple/optiontransferselect.ftl. The problematic instruction: ---------- ==> ${parameters.id} [on line 36, column 58 in template
Inappropriate OGNL expression
提示错误ognl.InappropriateExpressionException: Inappropriate OGNL expression: PREVIOUS_REQUEST_PARAMETER_MAP_companyMenu&dotcurrentCityCompany&dotcompanyId 问题是你的隐藏域的无值,但是你还直接使用了它,把它当做参数传了!还是好好检查下你关于此页面的所有