DEV Community

Gangbaolede Li
Gangbaolede Li

Posted on

Codeforces 4A: Watermelon

  • It's easy to see that odd number cannot be sum of two even numbers because sum of two even numbers is even.
  • On the other hand, even number can always be split into two positive even numbers except 2 because zero is not positive.

Problem statement:
https://codeforces.com/contest/4/problem/A

Python

def solve(weight):
    if weight > 2 and weight % 2 == 0:
        print("YES")
    else:
        print("NO")

w = int(input())
solve(w)
Enter fullscreen mode Exit fullscreen mode

C++

#include <iostream>
using namespace std;

int main() {
    int w;
    cin >> w;
    if (w > 2 && w % 2 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}
Enter fullscreen mode Exit fullscreen mode

Let me know your thoughts in the comments section below. Thanks!

Top comments (0)

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay