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 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:
gcd∗(lcm†(a,b),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) and (a2,b2,c2) are considered different if a1=a2, or b1=b2, or c1=c2.
∗gcd(x,y) denotes the greatest common divisor (GCD) of integers x and y.
†lcm(x,y) denotes the lowest common divisor (LCM) of integers x and y.
寒意顺着你的脊背流下……
——《泰拉瑞亚》
在召唤下一个 Boss —— 克苏鲁之脑后,你注意到它周围环绕着 n 只眼睛,编号从 1 到 n。在一次攻击中,克苏鲁之脑会选出一个三元组(眼睛编号)(a,b,c)(a,b,c 不必互不相同)。当且仅当满足以下条件时,该眼睛三元组被称为“猩红三元组”:
gcd∗(lcm†(a,b),lcm(b,c))=gcd(a,c),
为击败 Boss,你需要计算克苏鲁之脑能选出多少种不同的猩红三元组。若 (a1,b1,c1) 与 (a2,b2,c2) 满足 a1=a2 或 b1=b2 或 c1=c2,则视为不同三元组。
∗ gcd(x,y) 表示整数 x 与 y 的最大公约数(GCD)。
† lcm(x,y) 表示整数 x 与 y 的最小公倍数(LCM)。
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤1000). The description of the test cases follows.
The only line of each test case contains one integer n (1≤n≤2⋅105) — the number of eyes of The Brain of Cthulhu.
It is guaranteed that the sum of n across all test cases does not exceed 2⋅105.
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤1000)。随后是各测试用例的描述。
每个测试用例仅一行,包含一个整数 n(1≤n≤2⋅105)——即克苏鲁之脑的眼睛数量。
保证所有测试用例的 n 值之和不超过 2⋅105。
输出格式
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 1 possible crimson triple: (1,1,1).
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).
在第一个测试用例中,存在 1 个可能的深红色三元组:(1,1,1)。
在第二个测试用例中,存在 5 个可能的深红色三元组:(1,1,1)、(1,1,2)、(2,1,1)、(2,1,2)、(2,2,2)。
输入解题思路,AI测评打分。不知道怎么写?