| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 11235 | Pascal's Triangle - Debugging |
|
| 11234 | Magic Square |
|
Description
In mathematics, Pascal's triangle is a triangular array of the binomial coefficients. The rows of Pascal's triangle are conventionally enumerated starting with row n = 0 at the top (the 0th row). The triangle may be constructed in the following manner: In row 0 (the topmost row), there is a unique non-zero entry 1. Each entry of each subsequent row is constructed by adding the number above and to the left with the number above and to the right, treating blank entries as 0.

Image from wikipedia: https://upload.wikimedia.org/wikipedia/commons/0/0d/PascalTriangleAnimated2.gif
In this debugging task, a program has been prepared for you (input values are not required). After setting the break points that specified, you have to demonstrate the following things:
- Show how this program work.
- Predict the new values of pointers.
This program stores a pascal's triangle in a 1D array. The storage is so compact that there is no spaces left. We will first build the triangle by pointers, and then output each row.
Figure out how these things work, and ask the TA to watch your demonstration.
Input
No input are required for this program.
Output
Print the first 5 rows of Pascal's triangle.
Sample Input Download
Sample Output Download
Partial Judge Code
11235.cppPartial Judge Header
11235.hTags
Discuss
Description
A magic squre is a matrix of numbers where every row, column and two diagonals sum to the same number. For example, integers from 1 to 9 can form a 3-by-3 magic square as follows:
6 1 8
7 5 3
2 9 4
In this problem, you have to calculate how many magic squares can be constructed given a set of integers with a restriction.
Input
The first line of the input: the number of test cases in this input.
This number is less than 10.
Each test case has two lines;
The first line of a test case contains the restriction in three numbers, x, y, value:
- x is the specified x coordinate, which should be 0, 1, or 2
- y is the specified y coordinate, which should be 0, 1, or 2
- value is some number in the given set(in the second line), and its position is at (x,y).
Notice that (0,0) is at the left-top position.
and the second line has 9 distinct integers which are the set of numbers to be constructed as 3-by-3 magic squares. All of them are representable in the int type of C.
Output
For each test case, you should calculate the number of magic squares that the 9 integers can construct, given the condition that the specified value is at the position (x, y).
For example, if a test case is like:
0 1 1
1 2 3 4 5 6 7 8 9
You are asked to calculate how many cases in the form
x x x
1 x x
x x x
is available, where x should be filled with remaining 8 numbers.
The answer of this part should be 2 becasue
6 7 2
1 5 9
8 3 4
and
8 3 4
1 5 9
6 7 2
are all the magic squares you can find.