#P10040. [CCPC 2023 北京市赛] 替换
[CCPC 2023 北京市赛] 替换
Problem Description
Given a string of length over the alphabet 01?.
For any , consider the string , where for :
- If
?, then . - Otherwise, if , then
0. - Otherwise, . You can compute by recursively finding .
It is easy to see that the alphabet of is 01. You need to compute, for all , the number of 1 in .
Input Format
The first line contains an integer , representing the length of the string.
The second line contains a string of length over the alphabet 01?.
Output Format
Output lines. On the -th line, output one integer representing the number of 1 in .
5
10?1?
3
4
2
3
2
Hint
10011, 10111, 10010, 10011, 10010.
Translated by ChatGPT 5