Group the Numbers
시간 제한1초메모리 제한2048 MB
정수 1부터 n까지를 크기가 같은 k개의 그룹으로 나눌 때, 그룹 합의 최댓값과 최솟값의 차이가 최소가 되도록 배정하는 문제입니다.
문제
Consider the set of all integers from to . Split these integers into equal-sized groups in such a way that the difference between the maximum and minimum sums of integers among all groups is minimized. Formally, if is the sum of integers in -th group, the following value should be minimized:
입력
The first line contains two integers and (; is divisible by ).
출력
For each group, print a line with all the integers belonging to that group. If there are multiple optimal answers, output any one of them.