結果

問題 No.1464 Number Conversion
コンテスト
ユーザー Theta
提出日時 2022-10-25 13:10:40
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
RE  
実行時間 -
コード長 601 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 345 ms
コンパイル使用メモリ 20,824 KB
実行使用メモリ 20,700 KB
最終ジャッジ日時 2026-03-24 20:50:27
合計ジャッジ時間 5,163 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25 WA * 2 RE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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