Codeforces Round 1115 (Div. 2)
E
世代三元组
Generational Triplets
Codeforces
2100
原题
← DF →

世代三元组AI (CI翻译)

You are given an integer $n$. Find the number of triplets of integers $(a, b, c)$ such that:

给定一个整数 $n$。请找出满足以下条件的整数三元组 $(a, b, c)$ 的数量:AI (CI翻译)
  • $1 \le a \lt b \lt c \le n$;
  • $a$, $b$, and $c$ form an arithmetic progression (i.e., $b - a = c - b$);
  • $a \oplus b \oplus c = 0$, where $\oplus$ denotes the bitwise XOR operation.
  • $1 \le a \lt b \lt c \le n$;
  • $a$、$b$ 和 $c$ 构成等差数列(即 $b - a = c - b$);
  • $a \oplus b \oplus c = 0$,其中 $\oplus$ 表示按位 XOR 运算。
AI (CI翻译)

As the answer may be huge, you are only asked to output the answer modulo $10^9+7$.

由于答案可能非常大,你只需要输出答案对 $10^9+7$ 取模后的结果。AI (CI翻译)

Input

输入格式

AI (CI翻译)

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.

每个测试包含多个测试用例。第一行包含测试用例数量 $t$($1 \le t \le 10^4$)。接下来是各测试用例的描述。AI (CI翻译)

Each test case contains a single integer $n$ ($3 \le n \le 10^{18}$).

每个测试用例包含一个整数 $n$($3 \le n \le 10^{18}$)。AI (CI翻译)

Output

输出格式

AI (CI翻译)

For each test case, output a single integer — the number of valid triplets $(a, b, c)$ modulo $10^9 + 7$, on a separate line.

对于每个测试用例,输出一个整数,即满足条件的三元组 $(a, b, c)$ 的数量对 $10^9 + 7$ 取模后的结果,每个测试用例输出一行。AI (CI翻译)

Note

说明

AI (CI翻译)

In the first testcase, for $n = 3$, the only valid triplet is $(1, 2, 3)$. It satisfies the arithmetic progression condition since $2 - 1 = 3 - 2 = 1$, and it satisfies the XOR condition since $1 \oplus 2 \oplus 3 = 0$.

在第一个测试用例中,当 $n = 3$ 时,唯一的合法三元组是 $(1, 2, 3)$。它满足等差数列条件,因为 $2 - 1 = 3 - 2 = 1$;同时也满足 XOR 条件,因为 $1 \oplus 2 \oplus 3 = 0$。AI (CI翻译)

For larger values of $n$, make sure to output the answer modulo $10^9 + 7$.

对于更大的 $n$,请注意输出答案对 $10^9 + 7$ 取模后的结果。 AI (CI翻译)

样例

Input #1
4
3
10
15
1000000000000000000
Output #1
1
2
5
353768760
InputCopy OutputCopy
题目信息
题号
2252E
时间限制
2 s
内存限制
256 MB
标签
位运算
组合数学
动态规划
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。