A15378 | Antifibonacci Cut
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Note that the memory limit is unusual.
Let's define the sequence of Fibonacci strings as follows: $f_0$ is 0, $f_1$ is 1, $f_i$ is $f_{i-1} + f_{i-2}$ for $i>1$ ( $+$ denotes the concatenation of two strings). So, for example, $f_2$ is 10, $f_3$ is 101, $f_4$ is 10110.
For a given string $s$ , let's define $g(s)$ as the number of ways to cut it into several (any number, possibly even just one) strings such that none of these strings are Fibonacci strings. For example, if $s$ is 10110101, $g(s) = 3$ since there are three ways to cut it:
- 101101 $+$ 01;
- 1011 $+$ 0101;
- 1011 $+$ 01 $+$ 01.
You are given a sequence of strings $s_1, s_2, \dots, s_n$ . Calculate $g(s_1), g(s_1 + s_2), \dots, g(s_1 + s_2 + \ldots + s_n)$ . Since these values can be huge, print them modulo $998244353$ .
Let's define the sequence of Fibonacci strings as follows: $f_0$ is 0, $f_1$ is 1, $f_i$ is $f_{i-1} + f_{i-2}$ for $i>1$ ( $+$ denotes the concatenation of two strings). So, for example, $f_2$ is 10, $f_3$ is 101, $f_4$ is 10110.
For a given string $s$ , let's define $g(s)$ as the number of ways to cut it into several (any number, possibly even just one) strings such that none of these strings are Fibonacci strings. For example, if $s$ is 10110101, $g(s) = 3$ since there are three ways to cut it:
- 101101 $+$ 01;
- 1011 $+$ 0101;
- 1011 $+$ 01 $+$ 01.
You are given a sequence of strings $s_1, s_2, \dots, s_n$ . Calculate $g(s_1), g(s_1 + s_2), \dots, g(s_1 + s_2 + \ldots + s_n)$ . Since these values can be huge, print them modulo $998244353$ .
输入格式
The first line of the input contains one integer $n$ ( $1 \le n \le 3 \cdot 10^3$ ).
Then, $n$ lines follow. The $i$ -th line contains the string $s_i$ ( $1 \le |s_i| \le 10^3$ ), consisting of characters 0 and/or 1.
Then, $n$ lines follow. The $i$ -th line contains the string $s_i$ ( $1 \le |s_i| \le 10^3$ ), consisting of characters 0 and/or 1.
输出格式
Print $n$ integers, where the $i$ -th integer is $g(s_1 + s_2 + \ldots + s_i) \bmod 998244353$ .
输入输出样例
输入 #1
1 10110101
输出 #1
3
输入 #2
3 1111 1 0
输出 #2
2 3 3
输入 #3
6 10110101 100100001110 0000001100010001 1111 1001010100101010101001 000100000010101111
输出 #3
3 561 1466229 9887505 972227653 52128355
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted