시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 1024 MB | 6 | 2 | 2 | 40.000% |
Let us consider a sequence of alternatively changing zeroes and ones, starting with one. This sequence can be seen as a binary representation of a positive integer. We want to present it as a sum of different binary numbers, composed only of ones (i.e. 1, 11, 111 and etc). For some sequences such presentation is possible, for others not.
For example: 10102=112+1112; 10101012=1112+11112+1111112; 101010101012 cannot be presented as desired.
Write a program to find for a given sequence of zeros and ones the number of summands in one presentation as a sum of different binary numbers, composed only of ones, or determines that there is no such presentation.
The first line of the standard input contains only one positive integer n – the length of the considered sequence.
The only line of the standard output should only contain one non-negative integer: the number of different summands of the desired presentation or 0, if there is no such presentation.
If there is more than one possible solution, output the number of summands in any of them.
번호 | 배점 | 제한 |
---|---|---|
1 | 10 | n ≤ 60 |
2 | 20 | n ≤ 103 |
3 | 30 | n ≤ 106 |
4 | 40 | n ≤ 2·109 |
6
4
1010102=12+112+1112+111112 (42=1+3+7+31)
5
0
The number 101012=21 cannot be presented as desired.