#AT1859. G - Power Pair
G - Power Pair
G - Power Pair
Score : $600$ points
Problem Statement
Given is a prime number $P$.
How many pairs of integers $(x, y)$ satisfy the following conditions?
- $0 \leq x \leq P-1$
- $0 \leq y \leq P-1$
- There exists a positive integer $n$ such that $x^n \equiv y \pmod{P}$.
Since the answer may be enormous, print it modulo $998244353$.
Constraints
- $2 \leq P \leq 10^{12}$
- $P$ is a prime number.
Input
Input is given from Standard Input in the following format:
Output
Print the answer modulo $998244353$.
3
4
Four pairs $(x, y) = (0, 0), (1, 1), (2, 1), (2, 2)$ satisfy the conditions.
11
64
998244353
329133417