結果

問題 No.1464 Number Conversion
ユーザー 330Xs330Xs
提出日時 2022-02-03 15:42:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 642 bytes
コンパイル時間 714 ms
コンパイル使用メモリ 87,296 KB
実行使用メモリ 71,792 KB
最終ジャッジ日時 2023-09-02 03:18:52
合計ジャッジ時間 4,227 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,108 KB
testcase_01 AC 71 ms
71,352 KB
testcase_02 AC 72 ms
71,380 KB
testcase_03 AC 73 ms
71,248 KB
testcase_04 WA -
testcase_05 AC 69 ms
71,656 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 70 ms
71,496 KB
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 AC 69 ms
71,308 KB
testcase_22 WA -
testcase_23 AC 70 ms
71,476 KB
testcase_24 AC 70 ms
71,248 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 70 ms
71,360 KB
testcase_28 AC 69 ms
71,336 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(a) + len(b) - 1)
        
        elem = math.gcd(bunsi,bunbo)
        bunsi //= elem
        bunbo //= elem
        print(str(bunsi) + '/' + str(bunbo))
else:
    print(''.join(x) + '/1')
0