CF335A.Banana

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Piegirl is buying stickers for a project. Stickers come on sheets, and each sheet of stickers contains exactly nn stickers. Each sticker has exactly one character printed on it, so a sheet of stickers can be described by a string of length nn . Piegirl wants to create a string ss using stickers. She may buy as many sheets of stickers as she wants, and may specify any string of length nn for the sheets, but all the sheets must be identical, so the string is the same for all sheets. Once she attains the sheets of stickers, she will take some of the stickers from the sheets and arrange (in any order) them to form ss . Determine the minimum number of sheets she has to buy, and provide a string describing a possible sheet of stickers she should buy.

输入格式

The first line contains string ss ( 1<=s<=10001<=|s|<=1000 ), consisting of lowercase English characters only. The second line contains an integer nn ( 1<=n<=10001<=n<=1000 ).

输出格式

On the first line, print the minimum number of sheets Piegirl has to buy. On the second line, print a string consisting of nn lower case English characters. This string should describe a sheet of stickers that Piegirl can buy in order to minimize the number of sheets. If Piegirl cannot possibly form the string ss , print instead a single line with the number -1.

输入输出样例

  • 输入#1

    banana
    4
    

    输出#1

    2
    baan
    
  • 输入#2

    banana
    3
    

    输出#2

    3
    nab
    
  • 输入#3

    banana
    2
    

    输出#3

    -1
    

说明/提示

In the second example, Piegirl can order 3 sheets of stickers with the characters "nab". She can take characters "nab" from the first sheet, "na" from the second, and "a" from the third, and arrange them to from "banana".

首页