A12453 | Modest Substrings
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You are given two integers $l$ and $r$ .
Let's call an integer $x$ modest, if $l \le x \le r$ .
Find a string of length $n$ , consisting of digits, which has the largest possible number of substrings, which make a modest integer. Substring having leading zeros are not counted. If there are many answers, find lexicographically smallest one.
If some number occurs multiple times as a substring, then in the counting of the number of modest substrings it is counted multiple times as well.
Let's call an integer $x$ modest, if $l \le x \le r$ .
Find a string of length $n$ , consisting of digits, which has the largest possible number of substrings, which make a modest integer. Substring having leading zeros are not counted. If there are many answers, find lexicographically smallest one.
If some number occurs multiple times as a substring, then in the counting of the number of modest substrings it is counted multiple times as well.
输入格式
The first line contains one integer $l$ ( $1 \le l \le 10^{800}$ ).
The second line contains one integer $r$ ( $l \le r \le 10^{800}$ ).
The third line contains one integer $n$ ( $1 \le n \le 2\,000$ ).
The second line contains one integer $r$ ( $l \le r \le 10^{800}$ ).
The third line contains one integer $n$ ( $1 \le n \le 2\,000$ ).
输出格式
In the first line, print the maximum possible number of modest substrings.
In the second line, print a string of length $n$ having exactly that number of modest substrings.
If there are multiple such strings, print the lexicographically smallest of them.
In the second line, print a string of length $n$ having exactly that number of modest substrings.
If there are multiple such strings, print the lexicographically smallest of them.
输入输出样例
输入 #1
1 10 3
输出 #1
3 101
输入 #2
1 11 3
输出 #2
5 111
输入 #3
12345 12346 6
输出 #3
1 012345
In the first example, string «101» has modest substrings «1», «10», «1».
In the second example, string «111» has modest substrings «1» ( $3$ times) and «11» ( $2$ times).
In the second example, string «111» has modest substrings «1» ( $3$ times) and «11» ( $2$ times).
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted