F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Divide the Stones

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 1962    Accepted Submission(s): 589
Special Judge


Problem Description
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?
 

Input
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.
 

Output
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.
 

Sample Input
1 4 2
 

Sample Output
yes 1 4 2 3
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 04:22:45, Gzip enabled