CF585F.Digits of Number Pi

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Vasily has recently learned about the amazing properties of number ππ . In one of the articles it has been hypothesized that, whatever the sequence of numbers we have, in some position, this sequence is found among the digits of number ππ . Thus, if you take, for example, the epic novel "War and Peace" of famous Russian author Leo Tolstoy, and encode it with numbers, then we will find the novel among the characters of number ππ .

Vasily was absolutely delighted with this, because it means that all the books, songs and programs have already been written and encoded in the digits of ππ . Vasily is, of course, a bit wary that this is only a hypothesis and it hasn't been proved, so he decided to check it out.

To do this, Vasily downloaded from the Internet the archive with the sequence of digits of number ππ , starting with a certain position, and began to check the different strings of digits on the presence in the downloaded archive. Vasily quickly found short strings of digits, but each time he took a longer string, it turned out that it is not in the archive. Vasily came up with a definition that a string of length dd is a half-occurrence if it contains a substring of length of at least , which occurs in the archive.

To complete the investigation, Vasily took 22 large numbers x,yx,y ( x<=yx<=y ) with the same number of digits and now he wants to find the number of numbers in the interval from xx to yy , which are half-occurrences in the archive. Help Vasily calculate this value modulo 109+710^{9}+7 .

输入格式

The first line contains string ss consisting of decimal digits ( 1<=s<=10001<=|s|<=1000 ) that Vasily will use to search substrings in. According to hypothesis, this sequence of digis indeed occurs in the decimal representation of ππ , although we can't guarantee that.

The second and third lines contain two positive integers x,yx,y of the same length dd ( x<=yx<=y , 2<=d<=502<=d<=50 ). Numbers x,yx,y do not contain leading zeroes.

输出格式

Print how many numbers in the segment from xx to yy that are half-occurrences in ss modulo 109+710^{9}+7 .

输入输出样例

  • 输入#1

    02
    10
    19
    

    输出#1

    2
    
  • 输入#2

    023456789
    10
    19
    

    输出#2

    9
    
  • 输入#3

    31415926535
    10
    29
    

    输出#3

    20
    
首页