F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Triangle Conjecture

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 248    Accepted Submission(s): 115
Special Judge


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
 

Author
°¢»Ô(helihui)
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 16:40:40, Gzip enabled