Problem 2999 --Divide the Stones

2999: Divide the Stones

"
Time Limit $3$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $1$ 正确数量 $0$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
There are n stones numbered from 1 to n. 
The weight of the i-th stone is i kilograms. We divide the stones into k groups. 
Each group consists of exactly stones. 
We define the weight of each group is sum of the stones’ weights in the group. 
Can we divide the stones so that the weights of all groups are same?
The first line of input contains an integer T (1 <= T <= 100) denoting the number of test cases. 
Each test case consists of one line containing two integers n (1 ≤ n ≤ 100000), k (k is divisor of n). 
It is guaranteed that the sum of n overall test cases does not exceed 500000.
For each test case, if you can’t divide into k groups satisfying condition, print “no”. 
Else if you can divide into k groups satisfying condition, print “yes” in one line and then print k lines. 
The i-th line represent the indices of stones belonging to the i-th group. 
If there are multiple solutions, you can print any of them.
1
4 2
yes
1 4
2 3

推荐代码 查看2999 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$ $ms]
内存最少[$ $KB]
第一AC
第一挑战 intLSY 475244 2019-09-27 21:15:01

赛题来源/所属竞赛 2019 Multi-University Training Contest 4 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛