编程介的小学生 2017-11-21 06:22 采纳率: 20.5%
浏览 572
已采纳

Triangle Conjecture

Problem Description
One could construct a triangle with the digit 1 to 9 as the figure below:

The triangle is the one that the sums of every four numbers on its three edges are all equals to 23. Moreover, 23 is the biggest summation one can get from this kind of arraignment of digits. Your task is even tougher, given a positive integer n, you should use integer from 1 to 3*(n-1) to construct triangle with equal summation of digits on the three edges and the summation is the biggest among all the possible arraignments. For example, if n = 4, then you should choose number from 1 to 3*(4-1).
For convenience, the output format for a certain triangle is like the example for the figured triangle above:
95 41 38 2 6 7
The numbers are separated by a single space in each row, and there are no spaces at the end of each row.
Note that there may be several solutions exist, arbitrary one of them will be accepted.

Input
The first line of the input contains a number t indicates the number of test cases. Following t lines, each line will contains only one integer n denoting the side length of the desired triangle. ( t≤20, 3≤n≤1000)

Output
For each test case, output the triangles one by one.

Sample Input
2
3
4

Sample Output
6
1 2
5 3 4
9
5 4
1 3
8 2 6 7

  • 写回答

1条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料