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 的乳牛經常混用這三種記法。牠們用 cowfix 寫表達式,只使用一位數和二元運算子 +、-。可按中序、前序、後序規則的任意混合解讀。例如 +54+-82 至少有兩種求值方式:

+ 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

+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.