#P9920. 「RiOI-03」变换,反演

    ID: 10355 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>数论洛谷原创Special Judge素数判断,质数,筛法洛谷月赛

「RiOI-03」变换,反演

Background

For the needs of this problem, we redefine multiplicative functions: it is not guaranteed that f(1)=1f(1)=1.

Problem Description

This is a non-traditional problem.

You are given a multiplicative function f(d)f(d). For each test point, we will provide in the attachment the values of g(n)=dnf(d)g(n)=\sum_{d|n}f(d) for kk selected terms mod 998244353\bmod\ 998244353, and this part will also appear in the input. Then, for each test point, there are tt queries. For each query, an integer dd is given; please output the value of f(d)mod998244353f(d)\bmod 998244353.

Input Format

The first line contains kk. Each of the next lines contains two positive integers, dd and g(d)g(d).

Then two numbers t,idt, id are given, representing the number of queries and the test point ID. For each query, one positive integer nn is given.

Output Format

For each query, output one non-negative integer representing the answer.

10
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10

3 -1
1
2
3

1
1
2

Hint

Sample Explanation

Since g(d)=dg(d)=d, we have f(d)=φ(d)f(d)=\varphi(d), so the result is correct.

Constraints

For each test point:

If you correctly answer the testdata with nkn\le k, you will get 20%20\% of the score.

If you correctly answer all testdata, you will get the remaining 80%80\%. So, if you cannot answer correctly, please output a random number to keep the format correct.

Constraints

Id\text{Id} Name\text{Name} Score\text{Score} nn\leq k=k= t=t=
00 Epsilon\text{Epsilon} 55 10610^6 100100 1010
11 Division\text{Division} 10910^9
22 Unknown\text{Unknown} 101810^{18} 11
33 Random\text{Random} 1010 10510^5
44 Double\text{Double} 10910^9 100100 1010
55 Hack\text{Hack} 3162331623 11
66 Square\text{Square} 1515 101810^{18} 100100 55
77 Poly\text{Poly} 2020 10910^9 10510^5 100100
88 Thanks\text{Thanks} 10510^5 44 10510^5

Translated by ChatGPT 5