結果
| 問題 | No.222 引き算と足し算 |
| コンテスト | |
| ユーザー |
steek79
|
| 提出日時 | 2015-10-21 21:23:58 |
| 言語 | PyPy2 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 86 ms / 1,000 ms |
| コード長 | 556 bytes |
| 記録 | |
| コンパイル時間 | 277 ms |
| コンパイル使用メモリ | 77,492 KB |
| 最終ジャッジ日時 | 2025-12-03 17:40:46 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 |
ソースコード
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
steek79