問題一覧 > 通常問題

No.751 Frac #2

レベル : / AI推定難易度 : 243 / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 220
作問者 : Mcpu3 / テスター : 37zigen
お気に入りにしたユーザー ProblemId : 2437 / 自分の提出
問題文最終更新日: 2018-12-07 22:03: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 203 (順位表) の他の問題:

Problem Statement

You are given a fraction in the following format.

Find a fraction equal to the given fraction that is either an irreducible fraction or a fraction whose denominator is $1$.

Input

$\begin {array} { l } n_1 \\ A_1 \ A_2 \ \cdots A_{ n_1 } \\ n_2 \\ B_1 \ B_2 \ \cdots B_{ n_2 } \end {array}$

Integers satisfying the following constraints are given.

  • $1 \leq n_1 \leq 10$
  • $1 \leq \vert A_i \vert \leq 10 \ ( 1 \leq i \leq n_1 )$
  • $1 \leq n_2 \leq 10$
  • $1 \leq \vert B_j \vert \leq 10 \ ( 1 \leq j \leq n_2 )$
  • Output

    Output the answer fraction in the format "numerator denominator".

    If the fraction is negative, attach the minus sign to the numerator.

    Sample

    Sample 1
    Input
    3
    1 8 3
    2
    6 10
    Output
    5 72
    Sample 2
    Input
    2
    -1 1
    3
    -1 1 -1
    Output
    -1 1

    提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。