#P1620. 漂亮字串
漂亮字串
Description
Caima thinks that and are the two most beautiful letters, and a string made of is a most beautiful string. Among these most beautiful strings, if every substring that contains only has length at most , every substring that contains only has length at most , and the whole string has at most letters and letters , then it is a super beautiful unbeatable string.
Now Caima wants to know how long the longest super beautiful unbeatable string can be. Please tell him.
Input Format
The input contains multiple lines, until the end of file.
Each line has four numbers, in order: $\rm count_{\tt O}, \rm count_{\tt X}, \rm max_{\tt O}, \rm max_{\tt X}$.
Output Format
For each set of testdata, output one line with a single number, the length of the longest super beautiful unbeatable string.
10 10 0 0
3 5 1 1
0
7
Hint
Sample 2 Explanation
- .
Constraints and Conventions
At most groups of testdata.
For of the testdata, $0 \le \rm count_{\tt O}, \rm count_{\tt X}, \rm max_{\tt O}, \rm max_{\tt X} \le 20$, and the number of groups of testdata does not exceed .
For all testdata, $0 \le \rm count_{\tt O}, \rm count_{\tt X}, \rm max_{\tt O}, \rm max_{\tt X} \le 10^6$.
Translated by ChatGPT 5
京公网安备 11011102002149号