#P8158. Central Moments of Force Components on a Unit Circle

    ID: 21340 Type: Default 1000ms 256MiB

Central Moments of Force Components on a Unit Circle

Central Moments of Force Components on a Unit Circle

In the 2D Cartesian coordinate system, consider a circle with radius \(1\) and center \((0,0)\). There are \(n\) equally spaced red points on the circle with one of them lying on the positive \(x\)-axis. NaCly_Fish stands at the origin and randomly chooses one of these red points with equal probability and pushes in its direction with a force of \(1\text{ N}\). Let the components of the force along the \(x\) and \(y\) axes be \(F_x\) and \(F_y\) respectively.

The k-th central moment of a random variable \(X\) is defined as \[ E\bigl((X - E(X))^k\bigr), \] where \(E(X)\) is the expectation of \(X\). In this problem, you are asked to compute the \(k\)-th central moments of \(F_x\) and \(F_y\).

Since the red points are uniformly distributed on the circle, we have \[ E(F_x) = \frac{1}{n}\sum_{j=0}^{n-1}\cos\Bigl(\frac{2\pi j}{n}\Bigr) = 0, \quad E(F_y) = \frac{1}{n}\sum_{j=0}^{n-1}\sin\Bigl(\frac{2\pi j}{n}\Bigr) = 0, \] for \(n>1\) (if \(n=1\), the single point is \((1,0)\), yielding \(F_x=1\) and \(F_y=0\)). Therefore, the \(k\)-th central moment equals the ordinary moment in this problem: \[ \mu_{x,k} = E(F_x^k)= \frac{1}{n}\sum_{j=0}^{n-1}\cos^k\Bigl(\frac{2\pi j}{n}\Bigr), \quad \mu_{y,k} = E(F_y^k)= \frac{1}{n}\sum_{j=0}^{n-1}\sin^k\Bigl(\frac{2\pi j}{n}\Bigr). \]

Using the identity \[ \cos^k \theta = \frac{1}{2^k} \sum_{m=0}^k \binom{k}{m}\cos((k-2m)\theta), \] we observe that \[ \mu_{x,k} = \frac{1}{2^k} \sum_{\substack{0\le m\le k \\ n\,\vert\,(k-2m)}} \binom{k}{m}, \] since \[ \frac{1}{n}\sum_{j=0}^{n-1}\cos\Bigl(\frac{2\pi (k-2m)j}{n}\Bigr) \;=\; \begin{cases}1, & \text{if } n\,\vert\,(k-2m),\\0,& \text{otherwise.}\end{cases} \]

Similarly, one may show that \[ \mu_{y,k} = \begin{cases} \frac{1}{2^k (-1)^{k/2}} \sum_{\substack{0\le m\le k \\ n\,\vert\,(k-2m)}} \binom{k}{m}(-1)^m, & \text{if } k \text{ is even},\\ 0, & \text{if } k \text{ is odd}. \end{cases} \]

It can be proved that the answers are always rational numbers. Therefore, output the answers modulo \(998244353\). The input consists of two integers \(n\) and \(k\). For the output, print two space-separated integers: the \(k\)-th central moment of \(F_x\) and \(F_y\) modulo \(998244353\).

inputFormat

The input consists of a single line containing two integers \(n\) and \(k\), where \(n\) is the number of red points on the circle and \(k\) is the order of the moment to compute.

n k

outputFormat

Output two space-separated integers: the \(k\)-th central moment of \(F_x\) and \(F_y\) (in that order) modulo \(998244353\).

sample

1 1
1 0