XOR和二叉树,用C语言计算,将结果输出,怎么实现的?

Problem Description
HazelFan wants to build a rooted tree. The tree has n nodes labeled 0 to n−1, and the father of the node labeled i is the node labeled ⌊i−1k⌋. HazelFan wonders the size of every subtree, and you just need to tell him the XOR value of these answers.

Input
The first line contains a positive integer T(1≤T≤5), denoting the number of test cases.
For each test case:
A single line contains two positive integers n,k(1≤n,k≤1018).

Output
For each test case:
A single line contains a nonnegative integer, denoting the answer.

Sample Input
2
5 2
5 3

Sample Output
7
6

https://www.cnblogs.com/cmmdc/p/7374225.html