#P7487. Absolute Degree and Irrelevance Degree

    ID: 20682 Type: Default 1000ms 256MiB

Absolute Degree and Irrelevance Degree

Absolute Degree and Irrelevance Degree

Let n and k be two positive integers. Define the absolute degree of a tuple \((x_1, x_2, \dots, x_t)\) (with \(t\ge 1\)) as

[ A(x_1,\dots,x_t)=1+e^{\frac{2\pi i;x_1\cdot x_2\cdots x_t}{n}}. ]

For a given \(t\) with \(1\le t\le k\), the irrelevance degree \(F(t)\) is defined as the product of the absolute degrees of all \(t\)-tuples whose components are chosen from \([1,n]\):

[ F(t)=\prod_{(x_1,\dots,x_t)\in[1,n]^t}\Bigl(1+e^{\frac{2\pi i; (x_1x_2\cdots x_t)}{n}}\Bigr). ]

It can be proved that when n is odd, \(F(t)\) is a positive integer. In fact, one may show that

[ F(t)=2^{S(t-1)}\quad\text{with}\quad S(0)=1 \quad\text{and}\quad S(t-1)=\sum_{(x_1,\dots,x_{t-1})\in[1,n]^{t-1}} \gcd(x_1\cdots x_{t-1},n)\text{ for }t\ge 2. ]

When n is even, note that there exists at least one factor \(1+e^{\pi i}=0\) in the product for \(t\ge 1\) and hence \(F(t)=0\).

Your task is: for every \(t\) in \(\{1,2,\dots,k\}\), compute \(F(t)\) modulo \(335544323\) (a prime number) and finally output the bitwise XOR of all these \(k\) values.

Input format: Two space‐separated integers \(n\) and \(k\).

Note: All formulas use \(\LaTeX\) notation.

inputFormat

The input consists of a single line containing two positive integers \(n\) and \(k\) (separated by a space).

If n is even then it can be shown that for any \(t\), \(F(t)=0\) and hence the answer is 0.

outputFormat

Output a single integer which is the XOR (bitwise exclusive OR) of \(F(1), F(2), \dots, F(k)\) modulo \(335544323\).

sample

3 3
524322