CF306A.Candies
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
波利卡普斯有 n 颗糖果和 m 位朋友(满足 n≥m)。他想为每位朋友准备一份新年礼物,每份礼物都由若干颗糖果组成。波利卡普斯打算把所有糖果全部送出,并希望以尽可能公平(即最均等)的方式分配。他希望选择一组数 ai,其中 ai 表示第 i 位朋友收到的糖果数量,使得最大的 ai 与最小的 ai 之间的差值尽可能小。
例如,若 n 能被 m 整除,则他将向所有朋友赠送相同数量的糖果,此时最大值 ai 与最小值 ai 相等,差值为零。
输入格式
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.
输入仅包含一行,为两个用空格分隔的正整数 n、m(1 ≤ n, m ≤ 100;n ≥ m),分别表示糖果的数量和 Polycarpus 的朋友数量。
输出格式
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.
输出所需的序列 a1,a2,...,am,其中 ai 表示第 i 位朋友收到的糖果数量。所有数 ai 必须为正整数,总和为 n,且最大值与最小值之差应尽可能小。
输入输出样例
输入#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.
以任意顺序输出 ai,数字之间用空格分隔。
输入解题思路,AI测评打分。不知道怎么写?