编程介的小学生 2017-12-07 07:25 采纳率: 0.4%
浏览 894
已采纳

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

展开全部

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-12-09 07:31
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部