2017 杭州CCPC HDU 6265 Master of Phi
You are given an integer n. Please output the answer of ∑ d ∣ n φ ( d ) × n d    m o d u l o    998244353. \sum\nolimits_{d|n}φ(d)×\frac{n}{d}\;modulo\;998244353. ∑d∣nφ(d)×dnmodulo998244353. n is represented in the form of factorization.
φ(n) is Euler’s totient function, and it is defined more formally as the number of integers k in the interval 1 ≤ k ≤ n for which the greatest common divisor gcd(n, k) is equal to 1.
For example, the totatives of n = 9 are the six numbers 1, 2, 4, 5, 7 and 8. They are all co-prime to 9, but the other three numbers in this interval, 3, 6, and 9 are not, because gcd(9, 3) = gcd(9, 6) = 3 and gcd(9, 9) = 9. Therefore, φ(9) = 6. As another example, φ(1) = 1 since for n = 1 the only
integer in the interval from 1 to n is 1 itself, and gcd(1, 1) = 1.
And there are several formulas for computing φ(n), for example, Euler’s product formula states like:
ϕ ( n ) = n ∏ p ∣ n ( 1 − 1 p ) , \phi(n) = n\prod\nolimits_{p|n}\left(1 - \frac{1}{p}\right), ϕ(n)=n∏p∣n(1−p1),
where the product is all the distinct prime numbers (p in the formula) dividing n.
Input
The first line contains an integer T (1 ≤ T ≤ 20) representing the number of test cases.
For each test case, the first line contains an integer m (1 ≤ m ≤ 20) is the number of prime factors.
The following m lines each contains two integers p i p_i pi and q i q_i qi (2 ≤ p i p_i pi ≤ 108, 1 ≤ q i q_i qi ≤ 108) describing that n contains the factor p i q i p_i^{qi} piqi, in other words, n = ∏ i = 1 m p i q i . n=∏^m_{i=1}p_i^{q_i}. n=∏i=1mpiqi. It is guaranteed that all pi are primenumbers and different from each other.
Output
For each test case, print the the answer modulo 998244353 in one line.
Example
standard input | standard output |
---|---|
2 2 2 1 3 1 2 2 2 3 2 |
15 168 |
Explanation
For first test case, n = 2 1 2^1 21 ∗ 3 1 3^1 31 = 6, and the answer is (φ(1)∗n/1+φ(2)∗n/2+φ(3)∗n/3+φ(6)∗n/6) mod 998244353 = (6 + 3 + 4 + 2) mod 998244353 = 15.
题意
首先给你一个数m,接着是m对数 p i p_i pi, q i q_i q