#P7487. 「Stoi2031」兰亭序

    ID: 6424 远端评测题 2000ms 128MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>数学递推递归O2优化素数判断,质数,筛法

「Stoi2031」兰亭序

Description

Yue likes complex numbers very much, especially complex numbers of the form e2πite^{2\pi it}. She chooses two positive integers n,kn,k, and calls 1+e2πix1xkn1+e^{\frac{2\pi i x_1 \dots x_k}{n}} the absolute degree of (x1,,xk)(x_1,\dots,x_k). The product of the absolute degrees of all (x1,,xk)(x_1,\dots,x_k) satisfying 1xin1 \le x_i \le n (i{1,2,,k})(i \in \{1,2,\dots,k\}) is called the irrelevance degree of (n,k)(n,k). Now she wants you to help her compute, for each t{1,2,,k}t \in \{1,2,\dots,k\}, the irrelevance degree of (n,t)(n,t), denoted as ansmod335544323ans \bmod{335544323}. Since it is too troublesome to report too many numbers, you only need to output the result of XOR-ing all answers together.

Input Format

One line with two positive integers n,kn,k.

Output Format

One line with one non-negative integer representing the answer.

15 2

201012023

1 3

2

521 6

262795752

6546546546546543 22211

388124125

Hint

Brief statement of the problem:

Given n,kn,k, for 1tk1 \le t \le k compute

$$\prod_{x_1=1}^{n}\prod_{x_2=1}^{n}\dots\prod_{x_t=1}^{n}\left( 1+e^{\frac{2\pi ix_1x_2\dots x_t}{n}} \right) \bmod{335544323}$$

Output the XOR-sum of all kk answers.

Here, eit=cost+isinte^{it}=\cos{t}+i\sin{t} holds for all tRt \in \mathbb{R}, and ii is the imaginary unit, satisfying i2=1i^2=-1.

Sample explanation:

For the first sample, when t=1,2t=1,2, the answers are 2,351843720888322,35184372088832 respectively. After taking modulo, they are 2,2010120212,201012021, and the XOR result is 201012023201012023.

For the second sample, when t=1,2,3t=1,2,3, all answers are 22, and the XOR result is 22.

Due to space limits, the remaining samples are not explained.

Constraints:

This problem uses bundled testcases. The limits and scores of each subtask are as follows:

Subtask No. nn \le kk \le Special constraint Score
11 1010 11 None 77
22 11 1010
33 1010 22
44 101810^{18} 10510^5 nn is even
55 1010 nk730n^k \le 730 1616
66 10910^9 10310^3 None 1919
77 101810^{18} 10510^5 3737

For 100%100\% of the testdata, 1n1018,1k1051 \le n \le 10^{18},1 \le k \le 10^5.

Translated by ChatGPT 5