CF1104A.Splitting into digits

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Vasya has his favourite number nn. He wants to split it to some non-zero digits. It means, that he wants to choose some digits d1,d2,…,dkd_1, d_2, \ldots, d_k, such that 1≤di≤91 \leq d_i \leq 9 for all ii and d1+d2+…+dk=nd_1 + d_2 + \ldots + d_k = n.

Vasya likes beauty in everything, so he wants to find any solution with the minimal possible number of different digits among d1,d2,…,dkd_1, d_2, \ldots, d_k. Help him!

瓦西娅有一个他最喜欢的数字 nn。他想将该数字拆分为若干个非零数字。也就是说,他希望选出一些数字 d1,d2,…,dkd_1, d_2, \ldots, d_k,使得对所有 ii 都有 1≤di≤91 \leq d_i \leq 9,且 d1+d2+…+dk=nd_1 + d_2 + \ldots + d_k = n。

瓦西娅在一切事物中都追求美感,因此他希望在所有满足条件的解中,找出一个使 d1,d2,…,dkd_1, d_2, \ldots, d_k 中不同数字的种类数最少的解。请帮助他!

输入格式

The first line contains a single integer nn — the number that Vasya wants to split (1≤n≤10001 \leq n \leq 1000).

第一行包含一个整数 nn —— Vasya 想要拆分的数字(1≤n≤10001 \leq n \leq 1000)。

输出格式

In the first line print one integer kk — the number of digits in the partition. Note that kk must satisfy the inequality 1≤k≤n1 \leq k \leq n. In the next line print kk digits d1,d2,…,dkd_1, d_2, \ldots, d_k separated by spaces. All digits must satisfy the inequalities 1≤di≤91 \leq d_i \leq 9.

You should find a partition of nn in which the number of different digits among d1,d2,…,dkd_1, d_2, \ldots, d_k will be minimal possible among all partitions of nn into non-zero digits. Among such partitions, it is allowed to find any. It is guaranteed that there exists at least one partition of the number nn into digits.

第一行输出一个整数 kk —— 表示该划分中数字的个数。注意,kk 必须满足不等式 1≤k≤n1 \leq k \leq n。
第二行输出 kk 个数字 d1,d2,…,dkd_1, d_2, \ldots, d_k,以空格分隔。所有数字必须满足不等式 1≤di≤91 \leq d_i \leq 9。

你需要找到 nn 的一个划分,使得 d1,d2,…,dkd_1, d_2, \ldots, d_k 中不同数字的个数在所有将 nn 划分为非零数字的划分中达到最小可能值。在所有满足该最小不同数字个数的划分中,任选其一即可。题目保证至少存在一种将 nn 划分为数字的方式。

输入输出样例

  • 输入#1

    1

    输出#1

    1
    1
  • 输入#2

    4

    输出#2

    2
    2 2
  • 输入#3

    27

    输出#3

    3
    9 9 9

说明/提示

In the first test, the number 11 can be divided into 11 digit equal to 11.

In the second test, there are 33 partitions of the number 44 into digits in which the number of different digits is 11. This partitions are [1,1,1,1][1, 1, 1, 1], [2,2][2, 2] and [4][4]. Any of these partitions can be found. And, for example, dividing the number 44 to the digits [1,1,2][1, 1, 2] isn't an answer, because it has 22 different digits, that isn't the minimum possible number.

在第一个测试中,数字 11 可以被划分为 11 个等于 11 的数字。

在第二个测试中,将数字 44 划分为若干数字(每个数字为一位数)且其中不同数字的个数恰好为 11 的划分方式共有 33 种。这些划分方式为 [1,1,1,1][1, 1, 1, 1]、[2,2][2, 2] 和 [4][4]。输出其中任意一种即可。例如,将数字 44 划分为数字 [1,1,2][1, 1, 2] 并非合法答案,因为该划分中包含 22 个不同的数字,而这不是可能的最小值。

输入解题思路,AI测评打分。不知道怎么写?

首页