QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 16 MB Total points: 100

#22824. Cowfix

Statistics

式は通常、二項演算子をオペランドの間に置く中置記法で書きます。例は 1+2、7*(5-3) です。前置記法では演算子を前に置き、+ 1 2、* 7 - 5 3 のようにします。後置記法では後に置き、1 2 +、7 5 3 - * のようにします。前置と後置は括弧を使いません。

Farmer John の牛はこの 3 記法をよく混ぜます。1 桁の数と二項演算子 +、- で cowfix の式を書きます。中置、前置、後置の規則を任意に混ぜて解釈できます。例えば +54+-82 は少なくとも 2 通りで評価できます:

+ 5 4 + - 8 2 = 9 + - 8 2 = 9 + 6 = 15
+ 5 4 + - 8 2 = + 9 - 8 2 = + 1 2 = 3

9-4+3 は $2$ と $8$ の両方になります。cowfix 式が与えられたとき、取り得る異なる値の個数を求めてください。入力は構文的に正しい cowfix 式と保証されます。

入力

空白を含まない高々 80 文字の文字列 1 個。

出力

異なる取り得る値の個数を 1 行に出力します。

入出力例

入力 1

+54+-82

出力 1

2

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.