CF1110H.Modest Substrings

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

You are given two integers ll and rr .

Let's call an integer xx modest, if lxrl \le x \le r .

Find a string of length nn , 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 ll ( 1l108001 \le l \le 10^{800} ).

The second line contains one integer rr ( lr10800l \le r \le 10^{800} ).

The third line contains one integer nn ( 1n20001 \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 nn 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» ( 33 times) and «11» ( 22 times).

首页