Codeforces 4A C++ Solution

Problem Link

Remarks:
  •  First, we want to make sure that the weight of the watermelon (w) is even. If the weight is not even, that it is impossible to satisfy the condition where the divided two parts would weigh even kilos. Therefore, we would print out "NO" if the weight is odd.
  • In the case that the weight of the watermelon (w) is indeed even, then we use nested for loops. The loops are set up in this way because we want to deal with only even numbers and we want to brute force the solution.

Comments