C - Candies

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 ai, where ai is the number of candies in the i-th friend's present, that the maximum ai differs from the least ai 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 ai won't differ from the minimum one.

Input

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.

Output

Print the required sequence a1, a2, ..., am, where ai is the number of candies in thei-th friend's present. All numbers ai must be positive integers, total up to n, the maximum one should differ from the minimum one by the smallest possible value.

Examples
Input
12 3
Output
4 4 4 
Input
15 4
Output
3 4 4 4 
Input
18 7
Output
2 2 2 3 3 3 3 
#include<stdio.h>
int main(void)
{
    int n,m,a,b,i,ar[1000];
    while(scanf("%d%d",&n,&m)!=EOF)
    {
         a=n%m;
         b=n/m;
        for(i=1;i<=m;i++) ar[i]=b;
        for(i=m-a+1;i<=m;i++)  ar[i]+=1;
        for(i=1;i<m;i++) printf("%d ",ar[i]);
        printf("%d\n",ar[i]);
    }


}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值