A9982 | Digits of Number Pi
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $d$ 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 $2$ large numbers $x,y$ ( $x<=y$ ) with the same number of digits and now he wants to find the number of numbers in the interval from $x$ to $y$ , which are half-occurrences in the archive. Help Vasily calculate this value modulo $10^{9}+7$ .
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 $d$ 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 $2$ large numbers $x,y$ ( $x<=y$ ) with the same number of digits and now he wants to find the number of numbers in the interval from $x$ to $y$ , which are half-occurrences in the archive. Help Vasily calculate this value modulo $10^{9}+7$ .
输入格式
The first line contains string $s$ consisting of decimal digits ( $1<=|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,y$ of the same length $d$ ( $x<=y$ , $2<=d<=50$ ). Numbers $x,y$ do not contain leading zeroes.
The second and third lines contain two positive integers $x,y$ of the same length $d$ ( $x<=y$ , $2<=d<=50$ ). Numbers $x,y$ do not contain leading zeroes.
输出格式
Print how many numbers in the segment from $x$ to $y$ that are half-occurrences in $s$ modulo $10^{9}+7$ .
输入输出样例
输入 #1
02 10 19
输出 #1
2
输入 #2
023456789 10 19
输出 #2
9
输入 #3
31415926535 10 29
输出 #3
20
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted