#K34152. Team Scheduling Problem

    ID: 25246 Type: Default 1000ms 256MiB

Team Scheduling Problem

Team Scheduling Problem

You are given two positive integers \(N\) and \(M\), representing the number of departments and the number of departments that can participate in a day, respectively. Your task is to schedule teams such that each day has exactly \(M\) departments participating, except possibly the last day, which may have fewer than \(M\) departments if \(N \bmod M \neq 0\).

The scheduling must follow the natural order of departments: from 1 to \(N\). The number of days required can be calculated as \(\lceil N/M \rceil = \frac{N+M-1}{M}\) (using integer arithmetic).

For example:

  • If \(N=7\) and \(M=3\), the teams would be scheduled as: [[1, 2, 3], [4, 5, 6], [7]].
  • If \(N=6\) and \(M=3\), the schedule is: [[1, 2, 3], [4, 5, 6]].

Your program should read input from stdin and write the output to stdout as described below.

inputFormat

The input consists of a single line containing two integers \(N\) and \(M\) separated by a space.

\(1 \leq N, M \leq 10^6\)

outputFormat

Output the schedule over multiple lines. Each line corresponds to a day and contains the department numbers (in order) scheduled for that day, separated by a single space.

## sample
7 3
1 2 3

4 5 6 7

</p>