시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 512 MB | 0 | 0 | 0 | 0.000% |
You are given an integer $A$ and a string $S$ which consists of the following 10 characters: an addition operator '+
', a digit '1
', '2
', ... , '9
'.
Count the number of subsequences of $S$ which satisfy the following conditions.
+
'.+
'.+
' does not appear consecutively in the subsequence.Note that a subsequence is a sequence that can be obtained from the given sequence by removing zero or more elements without changing the order of the remaining elements.
Two subsequences are considered different if the set of removed elements' indices are different.
The input consists of a single test case in the format below.
$S$
$A$
The first line contains a single string $S$ ($1 \le |S| \le 36$). Each character of $S$ is either '+
', or a digit between '1
' and '9
'. The second line contains a single integer $A$ ($1 \le A \le 10^{18}$).
Output the number of subsequences which satisfy the given conditions in a single line.
1+2+3+4+5+6 18
9
+391+49++21+9934 43
47
1111111111111111 1111111111
8008