問題一覧 > 通常問題

No.222 Subtraction and Addition

レベル : / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 332
作問者 : shimomire
お気に入りにしたユーザー ProblemId : 211 / 自分の提出
問題文最終更新日: 2026-06-25 02:31:54
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 108 (順位表) の他の問題:

Problem Statement

A sensible person would interpret the string "x+y" as x + y and the string "x-y" as x - y.
However, Alice has addition and subtraction mixed up.
That is, she interprets the string "x+y" as x - y and the string "x-y" as x + y.
Given an input string, output the result of the operation under Alice's interpretation.

Input

$x$$op$$y$

$-10000 \le x \le 10000$
$op$ is "+" or "-"
$-10000 \le y \le 10000$
$x$,$y$ are integers and may have a leading sign (+,-).
(For example, if the integer is 0, there are 3 possible inputs: +0,-0,0. If the integer is 1, there are 2 possible inputs: +1,1. If the integer is -1, there is 1 possible input: -1.)

Note that there are no spaces between $x$,$op$,$y$.

Output

Output the resulting value on one line. Print a newline at the end.

Sample

Sample 1
Input
5+3
Output
2

The input is 5+3, but output 2, which is the result of the operation 5 - 3.

Sample 2
Input
10-20
Output
30

Sample 3
Input
-2+-3
Output
1

The input x,y may include signs.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。