CF2238B.Crimson Triples

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Chills run down your spine...

— Terraria

After summoning the next boss — The Brain of Cthulhu, you noticed that it surrounds itself with nn eyes, numbered from 11 to nn. In one attack, The Brain of Cthulhu chooses a triple of eyes (not necessarily distinct) with numbers (a,b,c)(a, b, c). The triple of eyes is called crimson if and only if the following property holds:

gcd⁡\gcd∗^{\text{∗}}(lcm⁡(\operatorname{lcm}†^{\text{†}}(a,b),lcm⁡(b,c))=gcd⁡(a,c)(a, b), \operatorname{lcm}(b, c)) = \gcd(a, c),

To defeat the boss, you want to know how many ways The Brain of Cthulhu can choose a crimson triple of eyes. The triples of eyes (a1,b1,c1)(a_1, b_1, c_1) and (a2,b2,c2)(a_2, b_2, c_2) are considered different if a1≠a2a_1 \neq a_2, or b1≠b2b_1 \neq b_2, or c1≠c2c_1 \neq c_2.

∗^{\text{∗}}gcd⁡(x,y)\gcd(x, y) denotes the greatest common divisor (GCD) of integers xx and yy.

†^{\text{†}}lcm⁡(x,y)\operatorname{lcm}(x, y) denotes the lowest common divisor (LCM) of integers xx and yy.

寒意顺着你的脊背流下……

——《泰拉瑞亚》

在召唤下一个 Boss —— 克苏鲁之脑后,你注意到它周围环绕着 nn 只眼睛,编号从 11 到 nn。在一次攻击中,克苏鲁之脑会选出一个三元组(眼睛编号)(a,b,c)(a, b, c)(a,b,ca,b,c 不必互不相同)。当且仅当满足以下条件时,该眼睛三元组被称为“猩红三元组”:

gcd⁡∗(lcm⁡†(a,b),lcm⁡(b,c))=gcd⁡(a,c),\gcd^{\text{∗}}(\operatorname{lcm}^{\text{†}}(a, b), \operatorname{lcm}(b, c)) = \gcd(a, c),

为击败 Boss,你需要计算克苏鲁之脑能选出多少种不同的猩红三元组。若 (a1,b1,c1)(a_1, b_1, c_1) 与 (a2,b2,c2)(a_2, b_2, c_2) 满足 a1≠a2a_1 \neq a_2 或 b1≠b2b_1 \neq b_2 或 c1≠c2c_1 \neq c_2,则视为不同三元组。

∗^{\text{∗}} gcd⁡(x,y)\gcd(x, y) 表示整数 xx 与 yy 的最大公约数(GCD)。

†^{\text{†}} lcm⁡(x,y)\operatorname{lcm}(x, y) 表示整数 xx 与 yy 的最小公倍数(LCM)。

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤10001 \le t \le 1000). The description of the test cases follows.

The only line of each test case contains one integer nn (1≤n≤2⋅1051 \le n \le 2 \cdot 10^5) — the number of eyes of The Brain of Cthulhu.

It is guaranteed that the sum of nn across all test cases does not exceed 2⋅1052 \cdot 10^5.

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

每个测试用例仅一行,包含一个整数 nn(1≤n≤2⋅1051 \le n \le 2 \cdot 10^5)——即克苏鲁之脑的眼睛数量。

保证所有测试用例的 nn 值之和不超过 2⋅1052 \cdot 10^5。

输出格式

For each test case, output one integer — the number of ways to choose a crimson triple of eyes.

对于每个测试用例,输出一个整数——选择一组绯红眼三元组的方法数。

输入输出样例

  • 输入#1

    3
    1
    2
    20

    输出#1

    1
    5
    612

说明/提示

In the first test case, there is 11 possible crimson triple: (1,1,1)(1, 1, 1).

In the second test case, there are 55 possible crimson triples: (1,1,1)(1, 1, 1), (1,1,2)(1, 1, 2), (2,1,1)(2, 1, 1), (2,1,2)(2, 1, 2), (2,2,2)(2, 2, 2).

在第一个测试用例中,存在 11 个可能的深红色三元组:(1,1,1)(1, 1, 1)。

在第二个测试用例中,存在 55 个可能的深红色三元组:(1,1,1)(1, 1, 1)、(1,1,2)(1, 1, 2)、(2,1,1)(2, 1, 1)、(2,1,2)(2, 1, 2)、(2,2,2)(2, 2, 2)。

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

首页