RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00083

Setnja

Gold I 골드 I
난이도
1s
시간 제한
32MB
메모리 제한
1
맞았습니다!!
1
제출 수
100.0%
정답률
레이팅

의견: 0

설명

In an infinite binary tree:

  • Each node has exactly two children – a left and a right child.
  • If a node is labeled with the integer \(X\), then its left child is labeled \(2 \cdot X\) and its right child \(2 \cdot X + 1\).
  • The root of the tree is labeled \(1\).

A walk on the binary tree starts in the root. Each step in the walk is either a jump onto the left child, onto the right child, or pause for rest (stay in the same node).

A walk is described with a string of letters L, R and P:

  • L represents a jump to the left child;
  • R represents a jump to the right child;
  • P represents a pause.

The value of the walk is the label of the node we end up on. For example, the value of the walk LR is \(5\), while the value of the walk RPP is \(3\).

A set of walks is described by a string of characters L, R, P and *. Each * can be any of the three moves; the set of walks contains all walks matching the pattern.

For example, the set L*R contains the walks LLR, LRR and LPR. The set ** contains the walks LL, LR, LP, RL, RR, RP, PL, PR and PP.

Finally, the value of a set of walks is the sum of values of all walks in the set.

Calculate the value of the given set of walks.

제약

In test data worth 30% points, there will be no characters ''.
In test data worth 50% points, there will be at most three characters '
'.

입력 형식

A string describing the set. Only characters L, R, P and * will appear and there will be at most \(10000\) of them.

출력 형식

Output the value of the set.

Scoring: In test data worth \(30\%\) of points, there will be no characters *. In test data worth \(50\%\) of points, there will be at most three characters *.

서브태스크
서브태스크점수설명

Subtask 1

36점

No * characters in the input.

Subtask 2

24점

At most three * characters.

Subtask 3

60점

No additional constraints.

예제 1
입력
P*P
출력
6
예제 2
입력
L*R
출력
25
예제 3
입력
**
출력
33
예제 4
입력
LLLLLRRRRRLLLLLRRRRRLLLLLRRRRRLLLLL
출력
35400942560
문제 정보

riseoj 작성

출처 COCI 2008/2009 Contest 2

평가 및 의견

Setnja

개요
출제자 난이도 Gold I 골드 I 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Setnja

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8