No.3186 Big Order
問題文最終更新日: 2025-06-21 18:44:00
English (AI translation)
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence.
Back to the original
yukicoder contest 471
(順位表)
の他の問題:
Problem Statement
You are given positive integers $A, B, C$. Find the number of times $A^B$ is divisible by $C$, modulo $998244353$.
Here, it is guaranteed that $C$ is at least $2$.
You are given $T$ test cases; find the answer for each of them.
Input
$T$Here, $\mathrm{case}_i$ denotes the $i$-th test case, and each test case is given in the following format.
$\mathrm{case}_1$
$\mathrm{case}_2$
$\vdots$
$\mathrm{case}_T$
$A\ \ B\ \ C$
- $1 \leq T \leq 100$
- $1 \leq A, B \leq 10^{40}$
- $2 \leq C \leq 10^{40}$
- All input values are integers.
Output
For each test case, print the number of times $A^B$ is divisible by $C$, modulo $998244353$, followed by a newline.
Sample
Sample 1
Input
3
2 3 4
1 2 3
2 1000000000 2
Output
1
0
1755647
- For the $1$-st test case, the number of times $A^B = 8$ is divisible by $4$ is $1$.
- For the $2$-nd test case, the number of times $A^B = 1$ is divisible by $3$ is $0$.
- For the $3$-rd test case, note that you must print the remainder when divided by $998244353$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
蜜蜂