Thursday 9 June 2016

Getting started with Codeforces: Part 5: Solving your second problem (Watermelon) in codeforces.

Actually this problem is easier than the first one.

You will be given a number, you have to print YES if the number can be divided into two even number, NO otherwise.

Solution strategy:

can you divide 8 into two even numbers?
Yes, because 2+6 or 4+4 
can you divide 9 into two even numbers? try all possible combination, the answer will be NO.

So, what we get so far is, if the number is even, we can divide it into two even numbers and if it's odd, we can not divide it into two even numbers.

Wait.... There is a critical case. How about 2?
even it's an even number, we can not divide it into two even number. only possible way is 1+1 where both are odd numbers. remember 0 is not considered here because it's not positive even number.

No comments:

Post a Comment