CF2147G.Modular Tetration
NOI/NOI+/CTSC
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
For a positive integer a, we define a recurrence bnn≥0 as bn=abn−1, with b0=1.
We say that a positive integer a is m-tetrative if the sequence b stabilizes to 1 modulo m, that is, there exists N≥0 such that bn≡1(modm) for all n≥N.
For a given m, calculate the density of the m-tetrative integers. Here, the density of a set S is the limit $$\lim\limits_{n\rightarrow \infty}\frac{|S\cap [1,2,\ldots,n]|}{n}.$$ Informally, it is the "proportion" of positive integers that are m-tetrative.
It can be proven (under the constraints of this problem) that the density is well-defined and is always a rational number, whose denominator is not divisible by 998244353.
对于正整数 a,我们定义一个递推序列 {bn}n≥0:bn=abn−1,其中 b0=1。
若正整数 a 满足:序列 b 在模 m 意义下稳定于 1,即存在 N≥0,使得对所有 n≥N 均有 bn≡1(modm),则称 a 是 m-四次幂型的(m-tetrative)。
对给定的 m,计算所有 m-四次幂型正整数的密度。此处,集合 S 的密度定义为极限
n→∞limn∣S∩[1,2,…,n]∣.
直观上,它表示正整数中 m-四次幂型整数所占的“比例”。
可以证明(在本题约束条件下),该密度恒存在,且总是一个有理数,其分母不被 998244353 整除。
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤104). The description of the test cases follows.
The number m will be given to you as a product of three integers x, y, and z. The first and only line of each test case contains three integers x, y, z (1≤x,y,z≤106, m=xyz≥2).
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤104)。随后是测试用例的描述。
数字 m 将以三个整数 x、y 和 z 的乘积形式给出。每个测试用例的第一行且唯一一行包含三个整数 x、y、z(1≤x,y,z≤106,且 m=xyz≥2)。
输出格式
For each test case, print the density of m-tetrative integers (a such that its corresponding sequence bn converges to 1 modulo m), modulo 998244353.
Formally, let M=998244353. It can be shown that the exact answer can be expressed as an irreducible fraction qp, where p and q are integers and q≡0(modM). Output the integer equal to p⋅q−1modM. In other words, output such an integer x that 0≤x<M and x⋅q≡p(modM).
对于每个测试用例,输出 m-四重幂整数(即满足其对应序列 bn 模 m 收敛于 1 的整数 a)的密度,对 998244353 取模。
形式化地,令 M=998244353。可以证明,精确答案可表示为既约分数 qp,其中 p 和 q 为整数,且 q≡0(modM)。请输出整数 p⋅q−1modM。换言之,输出满足 0≤x<M 且 x⋅q≡p(modM) 的整数 x。
输入输出样例
输入#1
5 5 1 1 5 2 1 23 1 1 10 10 2 9 3 37
输出#1
499122177 299473306 893685162 913393583 705965601
说明/提示
In the first test case, m=5. For example, a=1 is 5-tetrative since bn=1 for all n. For a=8, the sequence b is [1,8,88,8(88),…], which is [1,3,1,1,…] if we look at it modulo 5. It can be proven that the sequence is always 1(mod5) for big enough n, so 8 is 5-tetrative. For a=10, the sequence b is [1,10,1010,10(1010),…], which is [1,0,0,0,…] if we look at it modulo 5. It can be proven that the sequence is always 0(mod5) for big enough n, so 10 is not 5-tetrative. The answer for the first test case is 21.
In the second test case, m=10 and the answer is 101.
In the third test case, m=23 and the answer is 50663.
In the fourth test case, m=200 and the answer is 2001.
In the fifth test case, m=999 and the answer is 2221.
在第一个测试用例中,m=5。例如,a=1 是 5-四叠数(5-tetrative),因为对所有 n 均有 bn=1。对于 a=8,序列 b 为 [1,8,88,8(88),…],若对其模 5 观察,则变为 [1,3,1,1,…]。可以证明:当 n 足够大时,该序列恒满足 bn≡1(mod5),因此 8 是 5-四叠数。对于 a=10,序列 b 为 [1,10,1010,10(1010),…],若对其模 5 观察,则变为 [1,0,0,0,…]。可以证明:当 n 足够大时,该序列恒满足 bn≡0(mod5),因此 10 不是 5-四叠数。第一个测试用例的答案为 21。
在第二个测试用例中,m=10,答案为 101。
在第三个测试用例中,m=23,答案为 50663。
在第四个测试用例中,m=200,答案为 2001。
在第五个测试用例中,m=999,答案为 2221。
输入解题思路,AI测评打分。不知道怎么写?