Binary String
시간 제한4초메모리 제한2048 MB
각 k마다 '?' 위치 i를 i-k의 값(또는 i<=k이면 0)으로 채우고, 완성된 문자열에서 1의 개수를 출력한다.
문제
You are given a string of length with elements from the character set "01?".
For every , consider the string where, for :
- If
?, then . - Otherwise, if , then
0. - Otherwise, , and you can recursively compute to obtain .
It is easy to see that the character set of is "01". You need to calculate the number of 1 in for all .
입력
The first line of input contains an integer () representing the length of the string.
The second line contains the string of length with elements from the character set "01?".
출력
Output lines, where the -th line contains an integer representing the number of 1 in .