Source file:
Input file: cake.in
Output file: cake.out

Input
The first line of the input file contains a positive integer N indicating the number of data sets to follow. Each of the following N lines contains the x and y coordinates of points A, B, C, D, S, T, U, and V respectively. These sixteen integers are separated by spaces.
Output
For each data set in the input file, output the areas of the separated sections in a descending order. Use spaces to separate these values. At the end, output the largest area from the N data sets in the last line.
Sample Input
2
0 4 16 4 0 0 16 0 4 4 8 0 15 4 10 0
-1 5 5 5 -1 0 5 0 0 5 0 0 -1 3 5 3
Sample Output
26.00 24.00 14.00
15.00 10.00 3.00 2.00
26.00
Remarks for review: The actual input data sets can include the following
cuts with coordinates x and y ranging from negative integers to zeroes
and positive integers.
A road map is constructed from numbers of piecewise intervals. Each piecewise intervals is represented by two end points encompassed with parenthesis, e.g., ((100,250), (250,350)). Each point belongs to a point in the 2D plane with two integer axis values, i.e., x value and y value. Define the terminology FIRST SEE set means that, given a specific point, all the piecewise intervals which can be seen (more than two points of the piecewise intervals) by the point in all the directions. In other meaning, the FIRST SEE set defines the set of piecewise interval which are not blocked by other intervals with the standpoint of the point in the 3600 directions. Given a series of piecewise interval represents some specific city road map and a given specific point, write a program to find the FIRST SEE set of the point?
Input File
The input file contains a series of piecewise interval which represent some specific road map and finally a given specific point. Each line specifies the interval, the given point and ends with *.
Line 1: ((100,250),(250,350))
Line 2: ( (u,v),(s,t))
.
Line n: (p1,p2)
Line 1:n+1: * end of input file
Output File:
((120,150),(180,300))
((150,450), (230,450))
((180,550),(200,460))
((100,100),((200,110))
((500,380),(550,250))
((100,100),((150,130))
(200,200)
*
Sample Output File:
((100,100),((150,130))
((100,100),((200,110))
((120,150),(180,300))
((150,450), (230,450))
((500,380),(550,250))
In this assignment we consider the problem of compressing a text string using a dictionary. The dictionary consists of (dictionary string, code word)-pairs, each representing the code word that can be used to replace a substring in the text. The code words are binary bit strings, not necessarily of equal length. The text compression problem is that of, given a text string over some finite alphabet and a dictionary, deciding the length of the shortest binary bit string which encodes the original text string.
text string : abcdef
Dictionary:
| Dictionary
string |
|
|
|
|
|
|
| Code word |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Clearly, Method 2 results in the shortest compressed string whose length is 3. Your job in this assignment is to find out the length of the shortest compressed string. If the text string cannot be compressed using the given dictionary, 0 should be returned. (For example, the text string abcxxx cannot be compressed using the dictionary in Example 1.)
The first line of the input file contains the text string to be compressed. Following this are (dictionary string, code word)-pairs, each of which occupies a line of the input file. (For the sake of simplicity, we assume that the text string is over the alphabet which consists of the 26 lower-case characters `a, b, c, , z. Examples of such text strings include: abcdef, thisisatextstring, and acmprogrammingcontest.
With respect to Example 1, the input and output files are the following
Input file:
abcdef
(a, 01)
(abc, 0)
(abcd, 1011)
(bcd, 1)
(def, 10)
(ef, 11)
Output file:
3
2
A cheating casino creates an electronic symbol-bar machine. This machine has 3 belts attached to 3 wheels. Symbols from A to y, are painted on each belt in alphabetic order. Figure 1 shows the display of this kind of machine. Totally there are 113 symbols printed on each belt. These symbols are orderly listed in Table 1. A belt will display the same symbols on the screen if a wheel rolls 113 steps. When the bar handle is pulled, each wheel will roll certain steps, according to three formulas. For example, if (6*N + 3) is the formula for the first wheels step-movement, where N is the Nth times the bar handle is pulled after the machine is reset, the first wheel will roll (6 * N + 3) steps and show another 3 symbols on the screen. Assume each wheel rolls on the same direction, from bottom to top according to Figure 1. Each wheel has different formula for directing how many steps to move its belt. The three formulas are specified as input data in this problem. Once 3 Js are displayed on the center row of the screen, it means a BINGO. One hundred times the bet will be rewarded to the gambler.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The input file contains (K+1) lines. Each line specifies the input data for each test.
Line 1: W, X, Y, a, b, c, d, e, f, A, B, C
Line 2: P, Q, R, s, t, u, v, w, x, D, E, F
Line K: I, J, K, m, n, o, p, q, r, X, Y, Z
Line (K+1): * .. end of input file
Output File
The output file contains K lines. Each line is the output for each input configuration listed in input file.
Line 1: abcd a numerical number
Line 2: efgh . a numerical number
.
Line K: wxyz a numerical number
Sample Input File
74 74 74 0 1 0 1 0 1 75 75 75
1 1 1 0 1 0 1 0 1 77 77 77
3 5 7 0 1 0 1 0 1 75 75 75
*
Sample Output File
112
110
impossible
Write a program that can understand and calculate the infix notation expressions. All the values given and to be evaluated are considered to be only integers. The possible symbols of the expression include integer values, arithmetic operators, special symbols, keywords, and variables.
The values are just ordinary integral literal strings. The arithmetic operators are ordinary binary operators including +, -, *, and /; The special symbols include the equal sign =, parentheses, ( and ), and the question mark ?. The possible variables are just single English alphabets ranging from a to z; these variables are initialized as zeros at first.
Each input line contains an assignment expression with a variable on the left-hand side, following by the equal sign in the middle. The right-hand side of the assignment expression will be an ordinary integral expression (possibly contains several variables); the value of the expression shall be assigned to the variable for later evaluation. If the right hand side expression is a question mark, output the value of the left-hand side variable. Further, the possible keywords in the input file include if, while, and end statements. The syntax and meaning of while statement is as follows:
while ( [exp] )
[assignment-statements]
end
Here the interpreter will evaluate the value of [exp], if the value of [exp] is not zero, then the [assignment-statements] will be repetitively evaluated until the value of [exp] equals to zero. The syntax and meaning of if statement is just like the while-statement except that the [assignment-statements] will be evaluated just once if the value of [exp] is not zero.
Note:
Several lines of expression described above. A single `0' (zero) in the input line signifies the end of input.
Output File
For each question marked expression, output the corresponding value of the variable in a line. Output a single star `*' to signify the end of outputs.
Sample Input
x = 4
y = 3 * x - 2
y = ?
z = 5 + 2 * y
z = ?
x = 7 - y / 3
x = ?
while ( x )
z = 2 * z
end
z = ?
0
Sample Output
10
25
4
400
*
Let (F, +,l
) be a field, and F[x] be the set of all polynomials
in x. That is, a
polynomial is
in
if and only if
for every
. If
,
then
is called the leading
coefficient of
, and we say
that
has degree
.
Let the field be
,
There are only two elements, 0 and 1, in
.
The addition in
is defined
as:
,
,
.
The subtraction operation is the same as addition. That is
,
,
.
The multiplication in
is
defined as:
,
,
.
Let
and
be two polynomials in
.
The addition, subtraction, multiplication, and division of
and
are defined similar
to its corresponding operation of the ordinary polynomials, except that
all operations should be computed in
as
defined above. For example,
.
A polynomial
is
in
I, if there is no polynomials
and
in
with degree at least 1, satisfying
.
In this problem, you are going to write a program to find prime polynomials
of degree 1 to degree
,
where
is a positive integer.
Input File
The input file contains only one positive integer
You may assume that
.
Output File
The output file should contain a set of prime polynomials
in
. For each degree
,
,
list the prime polynomial
with smallest
. The format
of the output file is shown in the Sample Output section.
Sample Input
5
Sample Output
x^1+x^0
x^2+x^1+x^0
x^3+x^1+x^0
x^4+x^1+x^0
x^5+x^2+x^0
The following figure shows a 3x3 grid puzzle.
|
|
|
|
|
|
|
|
|
|
|
|
Movement :
0 stands for blank cell. You may move the number next
to 0 to blank cell.
Then 0 will occupy the cell that the number moves away.
The cost of this movement is exactly the number moved.
For example :
|
|
|
|
|
|
|
|
| <TD VALIGN=TOP WIDTH="3 |