問題一覧 > 通常問題

No.2125 Inverse Sum

レベル : / AI推定難易度 : 1500 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 73
作問者 : 👑 qand / テスター : 👑 potato167 とりゐ
お気に入りにしたユーザー ProblemId : 6483 / 自分の提出
問題文最終更新日: 2023-05-31 10:38:41
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

  • $1\le P,Q\le 10^9$
  • All input values are integers.
  • 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もしくは右上の雲マークをクリックしてアカウントを作成してください。