CF1045H.Self-exploration

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 c00c_{00} , c01c_{01} , c10c_{10} and c11c_{11} , representing how many times substrings 00, 01, 10 and 11 appear in the number respectively. For example:

10111100c00=1, c01=1, c10=2, c11=310111100 \rightarrow c_{00} = 1, \ c_{01} = 1,\ c_{10} = 2,\ c_{11} = 3

10000c00=3, c01=0, c10=1, c11=010000 \rightarrow c_{00} = 3,\ c_{01} = 0,\ c_{10} = 1,\ c_{11} = 0

10101001c00=1, c01=3, c10=3, c11=010101001 \rightarrow c_{00} = 1,\ c_{01} = 3,\ c_{10} = 3,\ c_{11} = 0

1c00=0, c01=0, c10=0, c11=01 \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 c00c_{00} , c01c_{01} , c10c_{10} and c11c_{11} constraints. Because of that he wanted to count how many binary numbers satisfy the constraints cxyc_{xy} given the interval [A,B][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 109+710^9 + 7 .

输入格式

First two lines contain two positive binary numbers AA and BB ( 1AB<21000001 \leq A \leq B < 2^{100\,000} ), representing the start and the end of the interval respectively. Binary numbers AA and BB have no leading zeroes.

Next four lines contain decimal numbers c00c_{00} , c01c_{01} , c10c_{10} and c11c_{11} ( 0c00,c01,c10,c111000000 \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][A, B] satisfy the constraints mod 109+710^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][10,1001] are 10,11,100,101,110,111,1000,100110,11,100,101,110,111,1000,1001 . Only number 110 satisfies the constraints: c00=0,c01=0,c10=1,c11=1c_{00} = 0, c_{01} = 0, c_{10} = 1, c_{11} = 1 .

Example 2: No number in the interval satisfies the constraints

首页