結果

問題 No.222 引き算と足し算
ユーザー steek79
提出日時 2015-10-21 21:23:58
言語 Python2
(2.7.18)
結果
AC  
実行時間 13 ms / 1,000 ms
コード長 556 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 6,948 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-15 22:05:41
合計ジャッジ時間 1,603 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

import re
inp = raw_input()

if inp[0] == '-':
    x_minus = True
    inp = inp[1:]
elif inp[0] == '+':
    x_minus = False
    inp = inp[1:]
else:
    x_minus = False

x = re.findall('^(\d*)[^\d*]', inp)
x = x[0]
inp = inp[len(x):]
x = int(x)

if x_minus == True:
    x = -x


op = inp[0]
inp = inp[1:]


if inp[0] == '-':
    y_minus = True
    inp = inp[1:]
elif inp[0] == '+':
    inp = inp[1:]
    y_minus = False
else:
    y_minus = False

y = int(inp)

if y_minus == True:
    y = -y
    

if op == '+':
    ans = x-y
else:
    ans = x+y

print ans
0