A9024 | Candies
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Polycarpus has got $n$ candies and $m$ friends ( $n>=m$ ). He wants to make a New Year present with candies to each friend. Polycarpus is planning to present all candies and he wants to do this in the fairest (that is, most equal) manner. He wants to choose such $a_{i}$ , where $a_{i}$ is the number of candies in the $i$ -th friend's present, that the maximum $a_{i}$ differs from the least $a_{i}$ as little as possible.
For example, if $n$ is divisible by $m$ , then he is going to present the same number of candies to all his friends, that is, the maximum $a_{i}$ won't differ from the minimum one.
For example, if $n$ is divisible by $m$ , then he is going to present the same number of candies to all his friends, that is, the maximum $a_{i}$ won't differ from the minimum one.
输入格式
The single line of the input contains a pair of space-separated positive integers $n$ , $m$ ( $1<=n,m<=100;n>=m$ ) — the number of candies and the number of Polycarpus's friends.
输出格式
Print the required sequence $a_{1},a_{2},...,a_{m}$ , where $a_{i}$ is the number of candies in the $i$ -th friend's present. All numbers $a_{i}$ must be positive integers, total up to $n$ , the maximum one should differ from the minimum one by the smallest possible value.
输入输出样例
输入 #1
12 3
输出 #1
4 4 4
输入 #2
15 4
输出 #2
3 4 4 4
输入 #3
18 7
输出 #3
2 2 2 3 3 3 3
Print $a_{i}$ in any order, separate the numbers by spaces.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted