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!

Discussion (0)