No.2125 Inverse Sum
問題文最終更新日: 2023-05-31 10:38:41
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 368
(順位表)
の他の問題:
Problem Statement
You are given positive integers $P,Q$.
Find all pairs of positive integers $(N,M)$ satisfying $\displaystyle\frac1N+\frac1M=\frac PQ$.Constraints
Input
$P$ $Q$
Output
Output in the following format.
$T$ $N_1$ $M_1$ $\vdots$ $N_T$ $M_T$Here, $T$ is the number of pairs $(N,M)$ satisfying the condition, and $(N_i,M_i)$ is the pair with the $i$-th smallest $N$ among the pairs satisfying the condition. It can also be proved that under the constraints, every $N_i,M_i$ fits in a 64-bit integer type.
Sample
Sample 1
Input
1 1
Output
1 2 2
The only $(N,M)$ satisfying $\displaystyle\frac1N+\frac1M=1$ is $(2,2)$.
Sample 2
Input
6 8
Output
2 2 4 4 2
Sample 3
Input
9 4
Output
0
There may be no pairs $(N,M)$ satisfying the condition.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
とりゐ