結果

問題 No.1464 Number Conversion
ユーザー Theta
提出日時 2022-10-25 13:10:40
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 601 bytes
コンパイル時間 205 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-07-03 12:36:48
合計ジャッジ時間 1,950 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25 WA * 2 RE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

def gcd(*numbers: int) -> int:
    if len(numbers) == 1:
        return numbers[0]
    if len(numbers) == 2:
        a, b = numbers
        if a < b:
            a, b = b, a

        while True:

            if a % b == 0:
                return b
            a, b = b, a % b

    first_gcd = gcd(*numbers[:2])
    return gcd(first_gcd, *numbers[2:])

def main():
    X = float(input())
    X_parent = int(1e8)
    X_child = int(X*X_parent)
    gcd_num = gcd(X_child, X_parent)
    X_child //= gcd_num
    X_parent //=gcd_num
    print(f"{X_child}/{X_parent}")


if __name__ == "__main__":
    main()
0