CF757D.Felicity's Big Secret Revealed

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

The gym leaders were fascinated by the evolutions which took place at Felicity camp. So, they were curious to know about the secret behind evolving Pokemon.

The organizers of the camp gave the gym leaders a PokeBlock, a sequence of nn ingredients. Each ingredient can be of type 00 or 11 . Now the organizers told the gym leaders that to evolve a Pokemon of type kk ( k>=2k>=2 ), they need to make a valid set of kk cuts on the PokeBlock to get smaller blocks.

Suppose the given PokeBlock sequence is b0b1b2... bn1b_{0}b_{1}b_{2}...\ b_{n-1} . You have a choice of making cuts at n+1n+1 places, i.e., Before b0b_{0} , between b0b_{0} and b1b_{1} , between b1b_{1} and b2b_{2} , ..., between bn2b_{n-2} and bn1b_{n-1} , and after bn1b_{n-1} .

The n+1n+1 choices of making cuts are as follows (where a | denotes a possible cut):

 b0  b1  b2  ...  bn2  bn1 |\ b_{0}\ |\ b_{1}\ |\ b_{2}\ |\ ...\ |\ b_{n-2}\ |\ b_{n-1}\ | Consider a sequence of kk cuts. Now each pair of consecutive cuts will contain a binary string between them, formed from the ingredient types. The ingredients before the first cut and after the last cut are wasted, which is to say they are not considered. So there will be exactly k1k-1 such binary substrings. Every substring can be read as a binary number. Let mm be the maximum number out of the obtained numbers. If all the obtained numbers are positive and the set of the obtained numbers contains all integers from 11 to mm , then this set of cuts is said to be a valid set of cuts.

For example, suppose the given PokeBlock sequence is 101101001110101101001110 and we made 55 cuts in the following way:

10  11  010  01  1  1010\ |\ 11\ |\ 010\ |\ 01\ |\ 1\ |\ 10 So the 44 binary substrings obtained are: 1111 , 010010 , 0101 and 11 , which correspond to the numbers 33 , 22 , 11 and 11 respectively. Here m=3m=3 , as it is the maximum value among the obtained numbers. And all the obtained numbers are positive and we have obtained all integers from 11 to mm . Hence this set of cuts is a valid set of 55 cuts.

A Pokemon of type kk will evolve only if the PokeBlock is cut using a valid set of kk cuts. There can be many valid sets of the same size. Two valid sets of kk cuts are considered different if there is a cut in one set which is not there in the other set.

Let f(k)f(k) denote the number of valid sets of kk cuts. Find the value of . Since the value of ss can be very large, output ss modulo 109+710^{9}+7 .

输入格式

The input consists of two lines. The first line consists an integer nn ( 1<=n<=751<=n<=75 ) — the length of the PokeBlock. The next line contains the PokeBlock, a binary string of length nn .

输出格式

Output a single integer, containing the answer to the problem, i.e., the value of ss modulo 109+710^{9}+7 .

输入输出样例

  • 输入#1

    4
    1011
    

    输出#1

    10
    
  • 输入#2

    2
    10
    

    输出#2

    1
    

说明/提示

In the first sample, the sets of valid cuts are:

Size 22 : |1|011, 1|01|1, 10|1|1, 101|1|.

Size 33 : |1|01|1, |10|1|1, 10|1|1|, 1|01|1|.

Size 44 : |10|1|1|, |1|01|1|.

Hence, f(2)=4f(2)=4 , f(3)=4f(3)=4 and f(4)=2f(4)=2 . So, the value of s=10s=10 .

In the second sample, the set of valid cuts is:

Size 22 : |1|0.

Hence, f(2)=1f(2)=1 and f(3)=0f(3)=0 . So, the value of s=1s=1 .

首页