鹿島建設プログラミングコンテスト2020 (AtCoder Regular Contest 110)
翻译中…
Problem Statement
翻译中…
Let $S$ be the concatenation of $10^{10}$ copies of the string 110. (For reference, the concatenation of $3$ copies of 110 is 110110110.)
翻译中…
We have a string $T$ of length $N$.
翻译中…
Find the number of times $T$ occurs in $S$ as a contiguous substring.
翻译中…
Constraints
翻译中…
$1 \leq N \leq 2 \times 10^5$$T$is a string of length$N$consisting of0and1.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N
T
翻译中…
Output
翻译中…
Print the number of times $T$ occurs in $S$ as a contiguous substring.
翻译中…
样例
Input #1
4
1011
Output #1
9999999999
$S$ is so long, so let us instead count the number of times `1011` occurs in the concatenation of $3$ copies of `110`, that is, `110110110`. We can see it occurs twice:
- $1$ `1011` $0110$
- $1101$ `1011` $0$
Input #2
22
1011011011011011011011
Output #2
9999999993
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。