AT_ttpc2019_i I hate P
题目描述
已知 $f(x)=\left\{\begin{matrix}
f\left(\dfrac{x}{P}\right)&\text{if}\ x\equiv 0\pmod{P} \\
x&\text{otherwise}
\end{matrix}\right.$。求 $\text{ans}=\left(\prod\limits_{i=L}^{R}{f(i)}\right)\pmod{Q}$,$P,Q,L,R$ 给定。
输入格式
```
P Q
L R
```
输出格式
```
ans
```
说明/提示
### 数据范围与约束:
保证:
- 输入的数均为正整数。
- $2 \leq P,Q \leq 10^7$
- $1 \leq L \leq R \leq 10^{18}$