Logo
(追記) (追記ここまで)

33417번 - Binary String 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 2048 MB111100.000%

문제

You are given a string $s_1 s_2 \ldots s_n$ of length $n$ with elements from the character set "01?".

For every $k \in [1, n],ドル consider the string $T_k = t_1 t_2 \ldots t_n$ where, for 1ドル \le i \le n$:

  • If $s_i \ne $?, then $t_i = s_i$.
  • Otherwise, if $i \le k,ドル then $t_i =$0.
  • Otherwise, $t_i = t_{i-k},ドル and you can recursively compute $t_{i-k}$ to obtain $t_i$.

It is easy to see that the character set of $T_k$ is "01". You need to calculate the number of 1 in $T_k$ for all $k \in [1, n]$.

입력

The first line of input contains an integer $n$ (1ドル \le n \le 10^5$) representing the length of the string.

The second line contains the string $s_1 s_2 \ldots s_n$ of length $n$ with elements from the character set "01?".

출력

Output $n$ lines, where the $k$-th line contains an integer representing the number of 1 in $T_k$.

제한

예제 입력 1

5
10?1?

예제 출력 1

3
4
2
3
2

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2024 > Day 2: CCPC Contest 1 B번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /