結果

問題 No.539 インクリメント
ユーザー fagfagdfafagfagdfa
提出日時 2017-08-24 02:38:48
言語 Python2
(2.7.18)
結果
RE  
実行時間 -
コード長 1,193 bytes
コンパイル時間 64 ms
コンパイル使用メモリ 6,940 KB
実行使用メモリ 17,496 KB
最終ジャッジ日時 2024-04-23 13:39:19
合計ジャッジ時間 4,303 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 WA -
testcase_02 TLE -
testcase_03 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = input()

for i in range(n):
    s = raw_input()
    tmp = ""
    raw = [0, 0]
    dot = 0
    for j in reversed(range(len(s))):
        ac = ord(s[j])
        if ac >= 48 and ac <= 57:
            if raw[1] == 0:
                raw[1] = j
            tmp += s[j]
        elif ac == 46:
            if j - 1 >= 0:
                if ord(s[j - 1]) >=48 and ord(s[j - 1]) <= 57:
                    tmp += s[j]
                    dot = 1
        elif len(tmp) > 0:
            if raw[0] == 0:
                raw[0] = j + 1
            break
    tmp = tmp[::-1]

    if dot == 0:
        ans = int(tmp)
        ans += 1
        a = ""
        a += s[0:raw[0]]
        a += str(ans)
        if len(a) != len(s):
            a += s[raw[1]:]
        print a
    else:
        a = "0."
        for i in reversed(range(len(tmp))):
            if tmp[i - 1] != '.':
                a += '0'
            else:
                a += '1'
                break
        ans = float(tmp) + float(a)
        a = str(ans)
        while len(a) != len(tmp):
            a += '0'
        b = ""
        b += s[0:raw[0]]
        b += a
        if len(b) != len(s):
            b += s[raw[1]:]
        print b
0