C++20 sections · 1024 units
Open in Course

Watermelon - The Idea

Main approach

The trick is that you need w>2w > 2 AND ww must be even. Why both conditions? Let me break it down for you. If ww is odd, any split gives one even and one odd part. For example, splitting 7 gives either 1+6, 2+5, or 3+4.

In each case, one number is odd. That fails the requirement since both parts must be even. If w=2w = 2, the only split is 1+11 + 1, but 1 is odd. So ww must be even AND greater than 2.

When both conditions hold, you can always split as 2+(w2)2 + (w-2), and both parts are even positive integers.