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.