結果
問題 |
No.222 引き算と足し算
|
ユーザー |
|
提出日時 | 2015-06-05 22:45:58 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 497 bytes |
コンパイル時間 | 130 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-11-15 21:25:49 |
合計ジャッジ時間 | 1,982 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 RE * 18 |
ソースコード
s = list(input()) a, b = 0, 0 op = "" minus = False if s[0] == "-": minus = True s.pop(0) idx = 0 while s[idx].isdigit(): idx += 1 num = int("".join(s[:idx])) s = s[idx:] a = num if not minus else -num op = s[0] if op == "+": op = "-" else: op = "+" s.pop(0) minus = False if s[0] == "-": minus = True s.pop(0) idx = 0 while idx < len(s) and s[idx].isdigit(): idx += 1 num = int("".join(s[:idx])) b = num if not minus else -num print(a-b if op == "-" else a+b)