CF1338C.Perfect Triples
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Consider the infinite sequence s of positive integers, created by repeating the following steps:
- Find the lexicographically smallest triple of positive integers (a,b,c) such that
- a⊕b⊕c=0 , where ⊕ denotes the bitwise XOR operation.
- a , b , c are not in s .
Here triple of integers (a1,b1,c1) is considered to be lexicographically smaller than triple (a2,b2,c2) if sequence [a1,b1,c1] is lexicographically smaller than sequence [a2,b2,c2] .
2. Append a , b , c to s in this order.
3. Go back to the first step.
You have integer n . Find the n -th element of s .
You have to answer t independent test cases.
A sequence a is lexicographically smaller than a sequence b if in the first position where a and b differ, the sequence a has a smaller element than the corresponding element in b .
输入格式
The first line contains a single integer t ( 1≤t≤105 ) — the number of test cases.
Each of the next t lines contains a single integer n ( 1≤n≤1016 ) — the position of the element you want to know.
输出格式
In each of the t lines, output the answer to the corresponding test case.
输入输出样例
输入#1
9 1 2 3 4 5 6 7 8 9
输出#1
1 2 3 4 8 12 5 10 15
说明/提示
The first elements of s are $1, 2, 3, 4, 8, 12, 5, 10, 15, \dots $