I need to split an MxN matrix into N parts with an even number of rows in each part. Moreover, the last part will be too much if the matrix is odd. But I don’t know which algorithm I should use. Can’t figure out how to do this. Tell me please

For example: we have matrix 5×5:

```
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
```

I need to divide it into 4 parts, I calculate the maximum possible number of divisions:

```
max_split = (h / 2) + (h % 2) = 2 + 1 = 3
```

After division, the first part looks like this:

```
1 2 3 4 5
6 7 8 9 10
```

Second part:

```
11 12 13 14 15
16 17 18 19 20
```

Third part:

```
21 22 23 24 25
```

Can you please tell me which algorithm should I use?

Source: Windows Questions C++