結果

問題 No.1464 Number Conversion
ユーザー 330Xs330Xs
提出日時 2022-02-03 15:46:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 627 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 87,264 KB
実行使用メモリ 71,700 KB
最終ジャッジ日時 2023-09-02 03:18:56
合計ジャッジ時間 3,668 ms
ジャッジサーバーID
(参考情報)
judge13 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,272 KB
testcase_01 AC 71 ms
71,356 KB
testcase_02 AC 71 ms
71,552 KB
testcase_03 AC 71 ms
71,580 KB
testcase_04 AC 73 ms
71,176 KB
testcase_05 AC 73 ms
71,328 KB
testcase_06 AC 72 ms
71,456 KB
testcase_07 AC 73 ms
71,560 KB
testcase_08 AC 72 ms
71,524 KB
testcase_09 AC 72 ms
71,468 KB
testcase_10 AC 71 ms
71,128 KB
testcase_11 AC 72 ms
71,556 KB
testcase_12 AC 72 ms
71,608 KB
testcase_13 AC 71 ms
71,328 KB
testcase_14 AC 72 ms
71,308 KB
testcase_15 AC 71 ms
71,700 KB
testcase_16 AC 71 ms
71,336 KB
testcase_17 AC 72 ms
71,556 KB
testcase_18 AC 72 ms
71,272 KB
testcase_19 AC 73 ms
71,320 KB
testcase_20 AC 72 ms
71,300 KB
testcase_21 AC 72 ms
71,140 KB
testcase_22 AC 72 ms
71,424 KB
testcase_23 AC 72 ms
71,364 KB
testcase_24 AC 73 ms
71,608 KB
testcase_25 AC 73 ms
71,320 KB
testcase_26 AC 72 ms
71,132 KB
testcase_27 AC 71 ms
71,656 KB
testcase_28 AC 74 ms
71,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
x = list(map(str,input()))
if('.' in x):
    a = []
    b = []
    flag = False
    for i in range(len(x)):
        if(x[i] == '.'):
            flag = True
        if(flag):
            if(x[i] != '.'):
                b.append(x[i])
        else:
            a.append(x[i])
    
    if((len(set(b)) == 1) & ('0' in set(b))):
        print(''.join(a) + '/1')
    else:
        bunsi = int(''.join(a) + ''.join(b))
        bunbo = 10 ** len(b)
        
        elem = math.gcd(bunsi,bunbo)
        bunsi //= elem
        bunbo //= elem
        print(str(bunsi) + '/' + str(bunbo))
else:
    print(''.join(x) + '/1')
0