| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 423 人关注过本帖
标题:[讨论]It's Logical
只看楼主 加入收藏
yelo20053533
Rank: 1
等 级:新手上路
帖 子:161
专家分:0
注 册:2006-11-27
收藏
 问题点数:0 回复次数:2 
[讨论]It's Logical

Description

At the University of Kentucky, they build a lot of high-performance computer hardware and software, often using one supercomputer to design the next. One of the most fundamental computer design problems is logic optimization: making sure that the optimized logic still computes the same function as the original design.

For this problem, your program will be given two logic expressions to compare for logical equivalence.

Input

The first line of the input consists of a positive integer n, which is the number of datasets (lines) that follow. Each dataset consists of a single line containing the two input expressions to be tested. The input expressions consist of any of 26 variables named a-z, the binary operators |, &, ^, (OR, AND and XOR respectively), the unary ~ (NOT),and parenthesis. The expressions should be evaluated ignoring all other characters and with operator precedence as in the C language (parenthesis, ~, &, ^, |). The two expressions will be input in sequence and it is up to your program to determine where one expression ends and the next begins.

Most logic manipulation programs would convert each expression into a normal form and check if the two normalized expressions are identical. Fortunately for you, each expression will consist of no more than 100 operations using no more than 10 different variables. For that many cases, you can test for equivalence by simply evaluating the two input expressions for all possible inputs and comparing the results.

Output

For each data set, print:

Data set N: Equivalent

if the expressions produce the same result, or:

Data set N: Different

if they produce different results. Of course N should be replaced by the data set number.

Sample Input

3
a ^b&(b|a)~b^ a
a^b&(b|a)(a^(b&(b|a)))
~~~~z~~z

Sample Output

Data set 1: Different
Data set 2: Equivalent
Data set 3: Equivalent

[此贴子已经被作者于2006-12-17 15:19:30编辑过]

搜索更多相关主题的帖子: Logical 
2006-12-17 15:18
yelo20053533
Rank: 1
等 级:新手上路
帖 子:161
专家分:0
注 册:2006-11-27
收藏
得分:0 
2006-12-17 15:18
哈哈546789
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2006-12-18
收藏
得分:0 
翻译????
2006-12-18 19:33
快速回复:[讨论]It's Logical
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022091 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved