Bitwise Triangles
시간 제한1초메모리 제한1024 MB
1부터 n까지의 정수로 이루어진 삼중항 중 임의의 두 수의 비트 AND가 0이 아닌 것들을 최대한 많이, 서로 겹치지 않게 골라 출력한다.
문제
We define a bitwise triangle to be a triplet of distinct integers with , , and , where \\& indicates the bitwise AND operator.
You are given an integer . We define a triangle packing to be a set of pairwise disjoint bitwise triangles consisting of integers from to inclusive. Find a maximal triangle packing (one with the maximum number of bitwise triangles).
입력
The first line of the input contains a single integer () --- the number of test cases. The description of the test cases follows.
Each test case consists of a single line containing one integer () --- the maximum allowed number in any of the triangles.
It is guaranteed that the sum of over all test cases does not exceed .
출력
The first line of output for each test case should contain a single integer () --- the size of the maximal triangle packing.
The next lines of output should each contain three distinct integers , , and (), representing one triangle of the maximal triangle packing.
If there are multiple solutions, print any.
힌트
In the first test case, we have . It can be shown that we cannot create any bitwise triangles from the set , so the size of the maximal packing is .
In the second test case, we have . The given triangle packing is valid since each of the three numbers in the one bitwise triangle are odd, and therefore the bitwise AND of any two of them is nonzero. It can be shown that this packing is maximal for .