#P17465. Bell 级数练习题

    ID: 19971 远端评测题 2500ms 512MiB 尝试: 0 已通过: 0 显示难度省选/NOI− 上传者: 标签>数学数论Dirichlet 卷积

Bell 级数练习题

Background

::::info[Concept Explanation]{open} For a positive integer NN, define the set

$$\mathcal D(N)=\left\{\left\lfloor\frac Nd\right\rfloor:1\le d\le N\right\}$$

Sort the numbers in D(N)\mathcal D(N) in increasing order as 1=d1<d2<⋯<dK=N1=d_1<d_2<\cdots<d_K=N.

Let F(n)=∑i=1nf(i)F(n)=\sum_{i=1}^n f(i) be the prefix sum function of f(n)f(n). In this problem, the block sieve of ff is defined as the following vector:

$$\mathbf B_f(N)=\left(F(d_1),F(d_2),\ldots,F(d_K)\right)$$

::::

Problem Description

You need to dynamically maintain the block sieve of a multiplicative function f(x)f(x).

More specifically, you are initially given the range NN and the values of ff at all prime powers not exceeding NN. Then there will be QQ operations, and each operation is one of the following two types:

  1. Given a prime pp, modify the point values of f(p),f(p2),…,f(p⌊log⁡pN⌋)f(p),f(p^2),\ldots,f(p^{\lfloor\log_p N\rfloor}).
  2. Query the block sieve of ff.

To avoid too much output, for a “query the block sieve of ff” operation, you only need to compute the following function:

$$S_f(N)=\bigoplus_{x\in\mathcal D(N)} x\left(F(x)\bmod 998244353\right)$$

Input Format

The first line contains two positive integers N,QN,Q.

In the next π(N)\pi(N) lines, in the ii-th line there are ⌊log⁡piN⌋\lfloor\log_{p_i}N\rfloor integers, where the jj-th number is f(pij)f(p_i^j). Here pip_i is the ii-th prime in increasing order.

In the next QQ lines, each line contains several integers. The first integer op\textit{op} indicates the type of the operation:

  • If op=1\textit{op}=1, the next integer is the prime pp to be modified, followed by ⌊log⁡pN⌋\lfloor\log_pN\rfloor integers, which are the new values of f(p),f(p2),…,f(p⌊log⁡pN⌋)f(p),f(p^2),\ldots,f(p^{\lfloor\log_pN\rfloor}) in order.
  • If op=2\textit{op}=2, you need to output the current value of Sf(N)S_f(N).

Output Format

Output several lines, each containing one non-negative integer, representing the value of Sf(N)S_f(N) for each query.

6 5
1 1
1
1
2
1 2 0 2
2
1 3 0
2
40
27
24

Hint

For 20%20\% of the testdata, NQ≤107NQ \le 10^7.
For another 30%30\% of the testdata, all operations with op=1\textit{op}=1 have the same pp.
For 100%100\% of the testdata, 2≤N≤1072\le N\le 10^7, 1≤Q≤3×1041\le Q\le 3\times10^4, op∈{1,2}\textit{op}\in\{1,2\}, 2≤p≤N2\le p\le N and pp is prime, and any given f(pk)f(p^k) satisfies 0≤f(pk)<9982443530\le f(p^k)<998244353.

The time limit is about 1.51.5 times the running time of std on the slowest case.

Translated by ChatGPT 5