A12142 | Self-exploration
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Being bored of exploring the Moon over and over again Wall-B decided to explore something he is made of — binary numbers. He took a binary number and decided to count how many times different substrings of length two appeared. He stored those values in $c_{00}$ , $c_{01}$ , $c_{10}$ and $c_{11}$ , representing how many times substrings 00, 01, 10 and 11 appear in the number respectively. For example:
$10111100 \rightarrow c_{00} = 1, \ c_{01} = 1,\ c_{10} = 2,\ c_{11} = 3$
$10000 \rightarrow c_{00} = 3,\ c_{01} = 0,\ c_{10} = 1,\ c_{11} = 0$
$10101001 \rightarrow c_{00} = 1,\ c_{01} = 3,\ c_{10} = 3,\ c_{11} = 0$
$1 \rightarrow c_{00} = 0,\ c_{01} = 0,\ c_{10} = 0,\ c_{11} = 0$
Wall-B noticed that there can be multiple binary numbers satisfying the same $c_{00}$ , $c_{01}$ , $c_{10}$ and $c_{11}$ constraints. Because of that he wanted to count how many binary numbers satisfy the constraints $c_{xy}$ given the interval $[A, B]$ . Unfortunately, his processing power wasn't strong enough to handle large intervals he was curious about. Can you help him? Since this number can be large print it modulo $10^9 + 7$ .
$10111100 \rightarrow c_{00} = 1, \ c_{01} = 1,\ c_{10} = 2,\ c_{11} = 3$
$10000 \rightarrow c_{00} = 3,\ c_{01} = 0,\ c_{10} = 1,\ c_{11} = 0$
$10101001 \rightarrow c_{00} = 1,\ c_{01} = 3,\ c_{10} = 3,\ c_{11} = 0$
$1 \rightarrow c_{00} = 0,\ c_{01} = 0,\ c_{10} = 0,\ c_{11} = 0$
Wall-B noticed that there can be multiple binary numbers satisfying the same $c_{00}$ , $c_{01}$ , $c_{10}$ and $c_{11}$ constraints. Because of that he wanted to count how many binary numbers satisfy the constraints $c_{xy}$ given the interval $[A, B]$ . Unfortunately, his processing power wasn't strong enough to handle large intervals he was curious about. Can you help him? Since this number can be large print it modulo $10^9 + 7$ .
输入格式
First two lines contain two positive binary numbers $A$ and $B$ ( $1 \leq A \leq B < 2^{100\,000}$ ), representing the start and the end of the interval respectively. Binary numbers $A$ and $B$ have no leading zeroes.
Next four lines contain decimal numbers $c_{00}$ , $c_{01}$ , $c_{10}$ and $c_{11}$ ( $0 \leq c_{00}, c_{01}, c_{10}, c_{11} \leq 100\,000$ ) representing the count of two-digit substrings 00, 01, 10 and 11 respectively.
Next four lines contain decimal numbers $c_{00}$ , $c_{01}$ , $c_{10}$ and $c_{11}$ ( $0 \leq c_{00}, c_{01}, c_{10}, c_{11} \leq 100\,000$ ) representing the count of two-digit substrings 00, 01, 10 and 11 respectively.
输出格式
Output one integer number representing how many binary numbers in the interval $[A, B]$ satisfy the constraints mod $10^9 + 7$ .
输入输出样例
输入 #1
10 1001 0 0 1 1
输出 #1
1
输入 #2
10 10001 1 2 3 4
输出 #2
0
Example 1: The binary numbers in the interval $[10,1001]$ are $10,11,100,101,110,111,1000,1001$ . Only number 110 satisfies the constraints: $c_{00} = 0, c_{01} = 0, c_{10} = 1, c_{11} = 1$ .
Example 2: No number in the interval satisfies the constraints
Example 2: No number in the interval satisfies the constraints
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted