#P2609. [ZJOI2012] 数列

    ID: 1622 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>数学高精度2012各省省选递归浙江

[ZJOI2012] 数列

Description

Xiaobai and Xiaolan are in a math class together. After class, the teacher assigns a homework problem: find the general term of the following sequence:

a0=0,a1=1,a2i=ai,a2i+1=ai+ai+1a_0=0,a_1=1,a_{2i}=a_i,a_{2i+1}=a_i+a_{i+1}

As a math enthusiast, Xiaobai quickly figures out the general term of this sequence. Xiaobai tells Xiaolan that he has solved it, but to prevent Xiaolan from copying, he does not want to reveal the formula. To show off while proving that he indeed solved it, Xiaobai comes up with a clever method: Xiaolan says a positive integer nn, and Xiaobai tells the value of ana_n. If Xiaobai can still quickly give the correct answer when nn is very large, it proves that he really has the formula. However, this method has a big flaw: Xiaolan cannot solve the problem himself, so he cannot verify whether Xiaobai’s answer is correct. As Xiaolan’s friend, can you help him?

Input Format

The first line of input contains exactly one positive integer TT, the number of test cases.

The next TT lines each contain an integer nn.

Output Format

For each test case, output a single integer representing ana_n on one line.

3
1
3
10

1
2
3

Hint

  • For 20% of the testdata, 1n1081 \le n \le 10^8.
  • For 50% of the testdata, 1n10121 \le n \le 10^{12}.
  • For 100% of the testdata, 1T201 \le T \le 20, 1n101001 \le n \le 10^{100}.

Translated by ChatGPT 5