Gym - 101810 I. Split the Number(拆分差最小)

I. Split the Number

time limit per test

1.0 s

memory limit per test

256 MB

input

standard input

output

standard output

You are given an integer x. Your task is to split the number x into exactly n strictly positive integers such that the difference between the largest and smallest integer among them is as minimal as possible. Can you?

Input

The first line contains an integer T (1 ≤ T ≤ 100) specifying the number of test cases.

Each test case consists of a single line containing two integers x and n (1 ≤ x ≤ 109, 1 ≤ n ≤ 1000), as described in the statement above.

Output

For each test case, print a single line containing n space-separated integers sorted in a non-decreasing order. If there is no answer, print  - 1.

Example

input

Copy

1
5 3

output

Copy

1 2 2

Note

The strictly positive integers are the set defined as: . That is, all the integers that are strictly greater than zero: .

 

除与余是关键运算

#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    int t,ans,m,i,k,n;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d",&n,&k);
        if(n<k)
        {
            printf("-1\n");
            continue;
        }
        ans=n/k;
        m=n%k;
        for(i=1;i<=k-m;i++)
        {
            printf("%d ",ans);
        }
        for(i=k-m+1;i<=k;i++)
        {
            if(i==k)
            printf("%d\n",ans+1);
            else
            printf("%d ",ans+1);
        }
    }
    return 0;
}

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值