結果

問題 No.1464 Number Conversion
ユーザー da_abda_ab
提出日時 2021-04-02 22:34:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 733 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 10,820 KB
実行使用メモリ 8,168 KB
最終ジャッジ日時 2023-08-25 12:45:26
合計ジャッジ時間 1,787 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,960 KB
testcase_01 AC 15 ms
8,128 KB
testcase_02 WA -
testcase_03 AC 15 ms
8,168 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 RE -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 15 ms
7,956 KB
testcase_24 AC 15 ms
8,128 KB
testcase_25 AC 15 ms
7,804 KB
testcase_26 WA -
testcase_27 AC 15 ms
7,864 KB
testcase_28 AC 15 ms
8,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 1464 Number Conversion

from sys import stdin

def dividePossibleTimes(x,n):
    t=0
    while True:
        x=x/n
        if not x.is_integer():
            break
        t+=1
    return t

x=float(stdin.readline())

decpart=x-int(x)
integer=x-decpart
if decpart==0:
    print('{}/1'.format(int(integer)))
    exit()
denominator=10**(len(format(decpart))-2)

decpart=format(decpart)[2:]
dp=int(decpart)

min2=min(dividePossibleTimes(dp,2),dividePossibleTimes(int(denominator),2))
min5=min(dividePossibleTimes(dp,5),dividePossibleTimes(int(denominator),5))

denominator=denominator/(2**min2)
dp=dp/(2**min2)
denominator=denominator/(5**min5)
dp=dp/(5**min5)

print('{0}/{1}'.format(int(integer*denominator+dp),int(denominator)))


0