编程介的小学生 2017-06-01 15:15 采纳率: 20.5%
浏览 676
已采纳

Sylvester construction

Problem Description
A Hadamard matrix of order n is an n * n matrix containing only 1s and -1s, called Hn, such that where is the n * n identity matrix. An interesting property of Hadamard matrices is that they have the maximum possible determinant of any n * n matrix with elements in the range [-1, 1]. Hadamard matrices have applications in errorcorrecting codes and weighing design problems.
The Sylvester construction is a way to create a Hadamard matrix of size 2n given . can be constructed as:

for example:

and so on.
In this problem you are required to print a part of a Hadamard matrix constructed in the way described above.

Input
The first number in the input is the number of test cases to follow. For each test case there are ve integers: n, x, y, w and h. n will be between 1 and 2^62 (inclusive) and will be a power of 2. x and y specify the upper left corner of the sub matrix to be printed, w and h specify the width and height respectively. Coordinates are zero based, so 0 <= x,y < n. You can assume that the sub matrix will t entirely inside the whole matrix and that 0 < w,h <= 20. There will be no more than 1000 test cases.

Output
For each test case print the sub matrix followed by an empty line.

Sample Input
3
2 0 0 2 2
4 1 1 3 3
268435456 12345 67890 11 12

Sample Output
1 1
1 -1

-1 1 -1
1 -1 -1
-1 -1 1

1 -1 -1 1 1 -1 -1 1 1 -1 -1
-1 -1 1 1 -1 -1 1 1 -1 -1 1
1 1 1 -1 -1 -1 -1 1 1 1 1
-1 1 -1 -1 1 -1 1 1 -1 1 -1
1 -1 -1 -1 -1 1 1 1 1 -1 -1
-1 -1 1 -1 1 1 -1 1 -1 -1 1
-1 -1 -1 -1 -1 -1 -1 1 1 1 1
1 -1 1 -1 1 -1 1 1 -1 1 -1
-1 1 1 -1 -1 1 1 1 1 -1 -1
1 1 -1 -1 1 1 -1 1 -1 -1 1
-1 -1 -1 1 1 1 1 1 1 1 1
1 -1 1 1 -1 1 -1 1 -1 1 -1

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-06-04 17:53
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本