CF2252E.Generational Triplets

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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

  • 1≤a<b<c≤n1 \le a \lt b \lt c \le n;
  • aa, bb, and cc form an arithmetic progression (i.e., b−a=c−bb - a = c - b);
  • a⊕b⊕c=0a \oplus b \oplus c = 0, where ⊕\oplus denotes the bitwise XOR operation.

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

给你一个整数 nn。请找出满足以下条件的整数三元组 (a,b,c)(a, b, c) 的个数:

  • 1≤a<b<c≤n1 \le a \lt b \lt c \le n;
  • aa、bb 和 cc 构成等差数列(即 b−a=c−bb - a = c - b);
  • a⊕b⊕c=0a \oplus b \oplus c = 0,其中 ⊕\oplus 表示按位异或运算。

由于答案可能非常大,你只需输出答案对 109+710^9+7 取模的结果。

输入格式

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

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

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤1041 \le t \le 10^4)。随后是测试用例的描述。

每个测试用例包含一个整数 nn(3≤n≤10183 \le n \le 10^{18})。

输出格式

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

对于每个测试用例,输出一行一个整数——满足条件的三元组 (a,b,c)(a, b, c) 的个数对 109+710^9 + 7 取模的结果。

输入输出样例

  • 输入#1

    4
    3
    10
    15
    1000000000000000000

    输出#1

    1
    2
    5
    353768760

说明/提示

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

For larger values of nn, make sure to output the answer modulo 109+710^9 + 7.

在第一个测试用例中,当 n=3n = 3 时,唯一有效的三元组是 (1,2,3)(1, 2, 3)。它满足等差数列条件,因为 2−1=3−2=12 - 1 = 3 - 2 = 1;同时也满足异或条件,因为 1⊕2⊕3=01 \oplus 2 \oplus 3 = 0。

对于更大的 nn 值,请确保输出答案对 109+710^9 + 7 取模的结果。

输入解题思路,AI测评打分。不知道怎么写?

首页