DWITE '09 R3 #3 - Binary Test Strings 2
View as PDFDWITE Online Computer Programming Contest, December 2009, Problem 3
The input will contain 5 lines, a binary string of length 1 to 8 — a pattern that should not appear in binary strings in the generated set.
That is: if the input is 1, then the only valid output string is 00000000 (any other binary string of size 8 will contain 1). A pattern 111111 blocks out:
00111111
01111110
01111111
10111111
11111100
11111101
11111110
11111111
The output will contain 5 lines, a sum of 1s present in the filtered sets.
Notes regarding the samples: 1 filters out everything but 00000000, which has no 1s, and so the sum is .
0 filters out everything but 11111111, there are eight 1s, so the sum is . The only pattern that
00000000 filters out is itself, which doesn't contribute to the sum anyway. All of the 8 bit binary strings: 1, 10, 11, …, 11111110, 11111111 contain
1s. Yes, I've counted them.
Sample Input
1
0
11
00
00000000
Sample Output
0
8
130
310
1024
Problem Resource: DWITE
Comments