CF1110H.Modest Substrings
NOI/NOI+/CTSC
通过率:0%
时间限制:5.00s
内存限制:1024MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given two integers l and r.
Let's call an integer x modest, if l≤x≤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.
给你两个整数 l 和 r。
我们称一个整数 x 是谦逊的(modest),当且仅当 l≤x≤r。
请构造一个长度为 n 的、仅由数字组成的字符串,使得该字符串中表示谦逊整数的子串数量尽可能多。带有前导零的子串不计入统计。如果存在多个满足条件的字符串,请输出字典序最小的一个。
若某个数字在字符串中作为子串多次出现,则在统计谦逊子串总数时,该数字也应被重复计数。
输入格式
The first line contains one integer l (1≤l≤10800).
The second line contains one integer r (l≤r≤10800).
The third line contains one integer n (1≤n≤2000).
第一行包含一个整数 l(1≤l≤10800)。
第二行包含一个整数 r(l≤r≤10800)。
第三行包含一个整数 n(1≤n≤2000)。
输出格式
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.
第一行输出最多可能的“谦逊子串”数量。
第二行输出一个长度为 n 的字符串,其恰好包含上述数量的“谦逊子串”。
若存在多个满足条件的字符串,请输出其中字典序最小的一个。
输入输出样例
输入#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).
在第一个例子中,字符串 «101» 的“谦逊子串”为 «1»、«10» 和 «1»。
在第二个例子中,字符串 «111» 的“谦逊子串”为 «1»(共 3 次)和 «11»(共 2 次)。
输入解题思路,AI测评打分。不知道怎么写?