#P17255. [Aboi 2077] 全部夢だった!
[Aboi 2077] 全部夢だった!
Background
Become a star floating in the moonlit night.
:::info[Noun Explanations] Define three types of congruence subgroups of modulo : :
$$\begin{aligned} \Gamma_0(N)&=\left\{\begin{bmatrix}a&b\\c&d\end{bmatrix}\in\text{SL}_2(\mathbb Z)\mathrel{\Bigg|}\begin{bmatrix}a&b\\c&d\end{bmatrix}\equiv\begin{bmatrix}*&*\\0&*\end{bmatrix}\pmod N\right\}\\ \Gamma_1(N)&=\left\{\begin{bmatrix}a&b\\c&d\end{bmatrix}\in\text{SL}_2(\mathbb Z)\mathrel{\Bigg|}\begin{bmatrix}a&b\\c&d\end{bmatrix}\equiv\begin{bmatrix}1&*\\0&1\end{bmatrix}\pmod N\right\}\\ \Gamma(N)&=\left\{\begin{bmatrix}a&b\\c&d\end{bmatrix}\in\text{SL}_2(\mathbb Z)\mathrel{\Bigg|}\begin{bmatrix}a&b\\c&d\end{bmatrix}\equiv\begin{bmatrix}1&0\\0&1\end{bmatrix}\pmod N\right\} \end{aligned}$$Here, means there is no restriction.
Define the cusps of a congruence subgroup as the equivalence classes of under the action of . Here, for $\gamma=\begin{bmatrix}a&b\\c&d\end{bmatrix}\in\Gamma$, the action is defined as . In particular, ; if the denominator is , then the value is .
Let be the number of cusps of the congruence subgroup . :::
Problem Description
Given a positive integer , for a given , compute , modulo .
Input Format
A single line with two integers . Here correspond to , respectively.
Output Format
Output one integer, the value of the answer modulo .
10 0
28
10 1
44
10 2
158
Hint
Subtask 1: , .
Subtask 2: , .
Subtask 3: , .
Translated by ChatGPT 5