1057 - I2P(I)2016_Yang_mid_1 Scoreboard

Time

2016/11/03 13:20:00 2016/11/03 15:10:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11186 Pascal's triangle
11187 Matrix manipulation
11188 Star

11186 - Pascal's triangle   

Description

As described in Wikipedia, Pascal's triangle is a triangular array of the binomial coefficients. The element k on row n of Pascal’s triangle can be calculated by the following relation:
C(n, 1) = 1, for n = 1, 2, …
C(n, n) = 1, for n = 1, 2, …
C(n, k) = C(n-1, k-1) + C(n-1, k),  for k = 2, 3, … and for n = 2, 3, …

Given a nonnegative integer M, display the Pascal’s triangle from row 1 to row M.
Use '%10d' to print each element. Print a newline '\n ' at the end of each row.

(Note that the sample output print only 1 blank within each element, which is wrong. You should use '%10d'.)

Input

A positive integer M (1<=M<=30)

Output

Print the Pascal triangle from level 1 to level M.

Sample Input  Download

Sample Output  Download

Tags




Discuss




11187 - Matrix manipulation   

Description

Given an N*N matrix (where 1 <= N <= 10), your job is to swap two specific rows i and j (where 0 <= i,j < N), and then rotate up column k (where 0 <= k < N) for one time.

 

For example:

 

Consider the following matrix and a given operation (i,j,k)=(1,3,1).

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

 

After the swap between rows 1 and 3, the matrix will become

 

1

2

3

4

5

16

17

18

19

20

11

12

13

14

15

6

7

8

9

10

21

22

23

24

25

 

Then, after rotating column 1, the matrix will become

 

1

17

3

4

5

16

12

18

19

20

11

7

13

14

15

6

22

8

9

10

21

2

23

24

25

 

You will be asked to perform such operations several times.

Input

The first line has N (1<=N<=10), which means the size of the matrix. The total number of elements in the matrix is thus N x N.

 

For the next N lines, each contains N integers, specifying the elements of the matrix. All of the integers in the same line are separated by a space.

 

The next line contains another integer M ( 0 < M <= 5 ), indicating the number of operations.

 

Finally in the last M lines, each contains 3 integers i,j,k ( 0 <= i,j,k < N ).

Output

The final matrix.

 

Print the elements of the matrix using the format "%3d".

 

Each row is ended with a newline character ' \n'.

Sample Input  Download

Sample Output  Download

Tags




Discuss




11188 - Star   

Description

Given two integers N and M, and a starting point with coordinates (x, y). You are asked to create an N-by-M matrix as follows.

  • Find the matrix element for the starting point, that is, with row index x and column index y, and set this element’s value as 'S'.
  • For a matrix element other than the starting point, if its row index is x or its column index is y, then set its value as '+'.
  • If a matrix element is on the diagonal line of the starting point, then set its value as '*'.
  • For all other matrix elements, set their values as '-'. 

Input

Four integers separated by blanks. The first integer (N) represents that the matrix has N rows. The second integer (M) represents that the matrix has M columns. The third integer (X) and the fourth integer (Y) represent the coordinates of the starting point.

( 1 <=N,M<= 15, 0 <= X < N, 0 <= Y < M )

 

Note that (0, 0) is on the most top-left of the matrix.

Output

The N-by-M matrix. Print the elements of the matrix using the format "%c". Each row is ended with a newline character '\n'.

Sample Input  Download

Sample Output  Download

Tags




Discuss