atcoder#NOMURA2020E. Binary Programming
Binary Programming
Score : points
Problem Statement
Takahashi has an empty string and a variable whose initial value is .
Also, we have a string consisting of 0
and 1
.
Now, Takahashi will do the operation with the following two steps times.
- Insert a
0
or a1
at any position of of his choice. - Then, increment by the sum of the digits in the odd positions (first, third, fifth, ...) of . For example, if is
01101
, the digits in the odd positions are0
,1
,1
from left to right, so is incremented by .
Print the maximum possible final value of in a sequence of operations such that equals in the end.
Constraints
- consists of
0
and1
.
Input
Input is given from Standard Input in the following format:
Output
Print the maximum possible final value of in a sequence of operations such that equals in the end.
1101
5
Below is one sequence of operations that maximizes the final value of to .
- Insert a
1
at the beginning of . becomes1
, and is incremented by . - Insert a
0
to the immediate right of the first character of . becomes10
, and is incremented by . - Insert a
1
to the immediate right of the second character of . becomes101
, and is incremented by . - Insert a
1
at the beginning of . becomes1101
, and is incremented by .
0111101101
26