|
||||||||||
Divide the StonesTime 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
Sample Output
Source | ||||||||||
|