結果

問題 No.1464 Number Conversion
ユーザー paruf4paruf4
提出日時 2021-04-10 16:50:27
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 966 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 86,948 KB
実行使用メモリ 78,836 KB
最終ジャッジ日時 2023-09-08 12:43:01
合計ジャッジ時間 4,443 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,100 KB
testcase_01 RE -
testcase_02 AC 81 ms
75,652 KB
testcase_03 AC 74 ms
71,344 KB
testcase_04 AC 76 ms
71,680 KB
testcase_05 AC 75 ms
71,696 KB
testcase_06 AC 74 ms
71,760 KB
testcase_07 AC 79 ms
75,688 KB
testcase_08 AC 80 ms
75,496 KB
testcase_09 AC 79 ms
75,668 KB
testcase_10 AC 78 ms
75,604 KB
testcase_11 AC 77 ms
75,376 KB
testcase_12 AC 72 ms
71,532 KB
testcase_13 AC 79 ms
75,512 KB
testcase_14 AC 76 ms
75,732 KB
testcase_15 AC 77 ms
75,604 KB
testcase_16 AC 76 ms
75,504 KB
testcase_17 AC 78 ms
75,788 KB
testcase_18 AC 81 ms
75,668 KB
testcase_19 AC 76 ms
75,816 KB
testcase_20 AC 76 ms
75,508 KB
testcase_21 AC 74 ms
71,476 KB
testcase_22 AC 125 ms
75,716 KB
testcase_23 AC 72 ms
71,448 KB
testcase_24 RE -
testcase_25 AC 125 ms
75,692 KB
testcase_26 AC 125 ms
75,744 KB
testcase_27 AC 72 ms
71,640 KB
testcase_28 AC 72 ms
71,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def factorization(n):
    retlist = []
    tmp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if tmp % i == 0:
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            retlist.append([i, cnt])

    if tmp != 1:
        retlist.append([tmp, 1])

    if retlist == []:
        retlist.append([n, 1])

    return retlist


s = input()
a = ""
b = ""
# print(s.find("."))
if s.find(".") != -1:
    a, b = s.split(".")
else:
    print(s+"/1")
    exit(0)

d = len(b)
ch = ""
f = False
for bb in b:
    if bb != "0":
        f = True
    if f:
        ch += bb

dch = factorization(int(ch)+int(a)*(10**d))
dmo = factorization(10**d)
div = []
for num_ch, val_ch in dch:
    for num_mo, val_mo in dmo:
        if num_ch == num_mo:
            div.append((num_ch, min(val_ch, val_mo)))
mo = 10**d
ch = int(ch)+int(a)*(10**d)
for dn, dv in div:
    mo //= dn**dv
    ch //= dn**dv

print(str(ch)+"/"+str(mo))
0