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)

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay