A12293 | Splitting into digits
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Vasya has his favourite number $n$ . He wants to split it to some non-zero digits. It means, that he wants to choose some digits $d_1, d_2, \ldots, d_k$ , such that $1 \leq d_i \leq 9$ for all $i$ and $d_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 $d_1, d_2, \ldots, d_k$ . Help him!
Vasya likes beauty in everything, so he wants to find any solution with the minimal possible number of different digits among $d_1, d_2, \ldots, d_k$ . Help him!
输入格式
The first line contains a single integer $n$ — the number that Vasya wants to split ( $1 \leq n \leq 1000$ ).
输出格式
In the first line print one integer $k$ — the number of digits in the partition. Note that $k$ must satisfy the inequality $1 \leq k \leq n$ . In the next line print $k$ digits $d_1, d_2, \ldots, d_k$ separated by spaces. All digits must satisfy the inequalities $1 \leq d_i \leq 9$ .
You should find a partition of $n$ in which the number of different digits among $d_1, d_2, \ldots, d_k$ will be minimal possible among all partitions of $n$ 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 $n$ into digits.
You should find a partition of $n$ in which the number of different digits among $d_1, d_2, \ldots, d_k$ will be minimal possible among all partitions of $n$ 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 $n$ into digits.
输入输出样例
输入 #1
1
输出 #1
1 1
输入 #2
4
输出 #2
2 2 2
输入 #3
27
输出 #3
3 9 9 9
In the first test, the number $1$ can be divided into $1$ digit equal to $1$ .
In the second test, there are $3$ partitions of the number $4$ into digits in which the number of different digits is $1$ . This partitions are $[1, 1, 1, 1]$ , $[2, 2]$ and $[4]$ . Any of these partitions can be found. And, for example, dividing the number $4$ to the digits $[1, 1, 2]$ isn't an answer, because it has $2$ different digits, that isn't the minimum possible number.
In the second test, there are $3$ partitions of the number $4$ into digits in which the number of different digits is $1$ . This partitions are $[1, 1, 1, 1]$ , $[2, 2]$ and $[4]$ . Any of these partitions can be found. And, for example, dividing the number $4$ to the digits $[1, 1, 2]$ isn't an answer, because it has $2$ different digits, that isn't the minimum possible number.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted