程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程解疑 >> matrix-Silver Matrix

matrix-Silver Matrix

編輯:編程解疑
Silver Matrix

Description

If a matrix satisfies the following conditions, we call it a silver matrix.

  1. The dimensions of the matrix are n * n.
  2. All its elements belong to the set S = {1, 2, 3, …, 2n - 1}.
  3. For every integer i (1 <= i <= n), all elements in the i-th row and i-th column make the set {1, 2, 3, …, 2n - 1}.

For example, the following 4 * 4 matrix is a silver matrix:

It is proved that silver matrix with size 2K * 2K always exists. And it is your job to find a silver matrix with size 2K * 2K.
Input

The input contains only an integer K (1 <= K <= 9).
Output

You may output any matrix with size 2K * 2K. To output a 2K * 2K matrix, you should output 2K lines, and in each line output 2K integers.
Sample Input

2
Sample Output

1 2 5 6
3 1 7 5
4 6 1 2
7 4 3 1

最佳回答:


http://tieba.baidu.com/p/1767207286

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved