Codeforces Round 1106 (Div. 2)
B
深红三元组
Crimson Triples
Codeforces
900
原题
← AC →

深红三元组AI (CI翻译)

Chills run down your spine...— Terraria

寒意沿着你的脊背蔓延……——《泰拉瑞亚》AI (CI翻译)

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

召唤下一个 Boss——克苏鲁之脑后,你发现它周围环绕着 $n$ 只眼睛,编号从 $1$ 到 $n$。每次攻击时,克苏鲁之脑会选择一组三元组眼睛(编号可以重复)$(a, b, c)$。当且仅当满足以下性质时,这组三元组眼睛称为深红三元组:AI (CI翻译)

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

$\gcd$$^{\text{∗}}$$(\operatorname{lcm}$$^{\text{†}}$$(a, b), \operatorname{lcm}(b, c)) = \gcd(a, c)$,AI (CI翻译)

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 $(a_1, b_1, c_1)$ and $(a_2, b_2, c_2)$ are considered different if $a_1 \neq a_2$, or $b_1 \neq b_2$, or $c_1 \neq c_2$.

为了击败 Boss,你想知道克苏鲁之脑有多少种方式可以选择深红三元组。若三元组眼睛 $(a_1, b_1, c_1)$ 和 $(a_2, b_2, c_2)$ 满足 $a_1 \neq a_2$、$b_1 \neq b_2$ 或 $c_1 \neq c_2$ 中的任意一项,则认为它们不同。AI (CI翻译)

$^{\text{∗}}$$\gcd(x, y)$ denotes the [greatest common divisor (GCD)](https://en.wikipedia.org/wiki/Greatest_common_divisor) of integers $x$ and $y$.$^{\text{†}}$$\operatorname{lcm}(x, y)$ denotes the least common multiple (LCM) of integers $x$ and $y$.

$^{\text{∗}}$$\gcd(x, y)$ 表示整数 $x$ 和 $y$ 的[最大公约数(GCD)](https://en.wikipedia.org/wiki/Greatest_common_divisor)。$^{\text{†}}$$\operatorname{lcm}(x, y)$ 表示整数 $x$ 和 $y$ 的最小公倍数(LCM)。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 1000$). The description of the test cases follows.

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

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

每个测试用例仅一行,包含一个整数 $n$($1 \le n \le 2 \cdot 10^5$),表示克苏鲁之脑的眼睛数量。AI (CI翻译)

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

保证所有测试用例的 $n$ 之和不超过 $2 \cdot 10^5$。AI (CI翻译)

Output

输出格式

AI (CI翻译)

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

对于每个测试用例,输出一个整数,表示选择深红三元组的方式数。AI (CI翻译)

Note

说明

AI (CI翻译)

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

第一个测试用例中,有 $1$ 个可能的深红三元组:$(1, 1, 1)$。AI (CI翻译)

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

第二个测试用例中,有 $5$ 个可能的深红三元组:$(1, 1, 1)$、$(1, 1, 2)$、$(2, 1, 1)$、$(2, 1, 2)$、$(2, 2, 2)$。AI (CI翻译)

样例

Input #1
3
1
2
20
Output #1
1
5
612
InputCopy OutputCopy
题目信息
题号
2238B
时间限制
1 s
内存限制
256 MB
标签
动态规划
数学
数论

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