编程介的小学生 2019-06-04 22:20 采纳率: 20.5%
浏览 266

求问条件不等式的比较判断和输出,怎么使用的C语言的程序代码编写的思想怎么解决问题的

Problem Description

When John studied the timed automaton, he met the problem about how to trigger the machine. With the problem deeply studied, he found that it can be ascribed to the clock constraints of the timed automaton. The timed automation in question is described below:

The clock variables, or simply clocks, are variables whose values are integers. Of course, time passes at the same rate for all clocks, and any clock can be reset to zero. John uses C to denote the finite set of clocks, and defines the clock constraints for C as follows:

(1)
All inequalities of the form t#c or c#t are clock constraints, where t is a clock, # is either < or <= , and c is an integer.
(2)
If A1 and A2 are clock constraints, then A1 ^ A2 is a clock constraint.

John notes that a clock constraint can define several regions in some multidimensional space. He wants to know such regions, so he defines the clock zones recursively as follows.

For simplicity, he let C0 = C {x0} , where x0 is a reference clock whose value is always 0. The clock zone A can be described by a Difference Bound Matrix D (called a DBM) which is a matrix (Dij) of size | C0|×| C0| . Each Dij has the form (dij,#) , where dij Z {$} , # { < ,<=} . The value of Dij can be evaluated in the following form:

For every inequality xi - xj#dij in clock zone A , let Dij = (dij,#) , where xi and xj are two clocks. If the bound of xi - xj for xi and xj is unknown, let Dij = ($, < ) .

For example, DBM of the clock zone given by x1 - x2 < 2 ^ 0 < x2<=2 ^ 1<=x1 is shown below:

The representation of a clock zone by a DBM is not unique. In this example, there are some implied constraints that are not reflected in the DBM. Since x1 - x2 < 2 and x2<=2 , it must be the case x1 < 4 . Since x0 = 0 , the original D10 = ($, < ) can be changed into D10 = (4, < ) . Such adjusting operation is called the tighten operation.

Now John wants to do the similar adjusting operations of difference bounds for all clocks xi and xj until further application of this tighten operation does not change the matrix. John obtains the following new canonical difference bound matrix:

Note that some clock zone may contain contrary conditions and has not canonical difference bound matrix.

But John can not obtain a canonical difference bound matrix for a complex clock zone. He asks for your help.

Input
The first line of the input file is a single integer T (1<=T<=20) , which is the number of test cases you must process, followed by T test cases:

Each test case consists of several lines. Four integers i , j , d and r are given on each line, representing a constraint xi - xj < d or xi - xj<=d (0<=i, j<=m, -10000 < d < 10000) . If r = 0 , then this line represents an inequality in the form of xi - xj < d , otherwise it represents an inequality in the form of xi - xj<=d . The maximal index m of clocks indicates that the indexes of the clocks are 0, 1,..., m,(1<=m<=100) . Note that you have to get the value of m by yourself.

A symbol # given on a single line indicates the end of a test case.

Output
For each test case, first output ``Case #:" on a single line, where # is the case number starting from 1. Print a blank line after each test case.

For each test case, output the description of the canonical difference bound matrix. If it doesn't have a canonical difference bound matrix, print ``Canonical DBM does not exist." (without quotes); If it has a such canonical difference bound matrix, print the matrix in the format as indicated in the sample output. Every element Dij of the matrix should be written in the form (dij,#) , where # is either < or <=. If the bound of xi - xj for xi and xj is unknown, print ($,<) at the position (i, j) . Two consecutive elements on each row should be separated by a single space.

Sample Input
1
1 2 2 0
0 2 0 0
2 0 2 1
0 1 -1 1
#

Sample Output
Case 1:
(0,<=) (-1,<=) (0,<)
(4,<) (0,<=) (2,<)
(2,<=) (1,<=) (0,<=)

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!
    • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
    • ¥15 求daily translation(DT)偏差订正方法的代码
    • ¥15 js调用html页面需要隐藏某个按钮