QOJ.ac

QOJ

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

#22824. Cowfix

Statistics

Le espressioni usano normalmente notazione infissa: operatore binario fra operandi, come 1+2 o 7*(5-3). Nella prefissa viene prima, come + 1 2 o * 7 - 5 3. Nella postfissa viene dopo, come 1 2 + o 7 5 3 - *. Prefissa e postfissa non usano parentesi.

Le mucche di Farmer John mescolano le tre. Scrivono in cowfix, usando numeri di una cifra e operatori binari + e -. Si può interpretare con qualunque miscela di regole infisse, prefisse e postfisse. Per esempio, +54+-82 ammette almeno due valutazioni:

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

9-4+3 vale sia $2$ che $8$. Data un’espressione cowfix, trovate il numero di valori distinti possibili. L’input è garantito sintatticamente valido in cowfix.

Input

Una stringa di al massimo 80 caratteri senza spazi.

Output

Una riga con il numero di diversi valori possibili.

Esempi

Input 1

+54+-82

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