B. Red and Blue Balls
time limit per test0.5 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
User ainta has a stack of n red and blue balls. He can apply a certain operation which changes the colors of the balls inside the stack.
While the top ball inside the stack is red, pop the ball from the top of the stack.
Then replace the blue ball on the top with a red ball.
And finally push some blue balls to the stack until the stack has total of n balls inside.
If there are no blue balls inside the stack, ainta can’t apply this operation. Given the initial state of the stack, ainta wants to know the maximum number of operations he can repeatedly apply.
Input
The first line contains an integer n (1 ≤ n ≤ 50) — the number of balls inside the stack.
The second line contains a string s (|s| = n) describing the initial state of the stack. The i-th charac

最低0.47元/天 解锁文章
390

被折叠的 条评论
为什么被折叠?



