結果

問題 No.222 引き算と足し算
コンテスト
ユーザー cologne
提出日時 2025-12-02 17:29:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 38 ms / 1,000 ms
コード長 530 bytes
記録
コンパイル時間 771 ms
コンパイル使用メモリ 82,612 KB
実行使用メモリ 53,768 KB
最終ジャッジ日時 2025-12-02 17:29:45
合計ジャッジ時間 2,833 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
from itertools import groupby


def input(): return sys.stdin.readline().rstrip('\n')


def main():
    s = input()
    xplus = +1
    if s.startswith('-') or s.startswith('+'):
        xplus = -1 if s.startswith('-') else +1
        s = s[1:]

    for sgn, yplus in [('+-', +1), ('--', -1), ('-+', +1), ('++', -1), ('-', +1), ('+', -1)]:
        k = s.split(sgn)
        if len(k) == 2:
            x, y = map(int, k)
            print(x * xplus + y * yplus)
            return


if __name__ == '__main__':
    main()
0