CF: 4A (Watermelon)


Problem link: http://codeforces.com/problemset/problem/4/A

Solution 1


// @BEGIN_OF_SOURCE_CODE

#include <cstdio>

using namespace std;

int main ()
{
    int n;

    scanf ("%d", &n);

    // if n is odd, ans is NO. Odd numbers can not be expressed as a sum of
    // two even numbers 
    if (n % 2 != 0) printf ("NO\n");
    
    // if n is even, but less than or equals to 2, ans is NO. 
    // possible values of n: 0 and 2 
    // NB: Both part should be even and POSITIVE (positive > 0)
    if (n <= 2) printf ("NO\n");
        
    else printf ("YES\n");

    return 0;
}

// @END_OF_SOURCE_CODE

Solution 2


// @BEGIN_OF_SOURCE_CODE

#include <cstdio>

using namespace std;

int main ()
{
    int n;

    scanf ("%d", &n);

    char yes [] = "YES\n";
    char no [] = "NO\n";

    if (n % 2 != 0) printf ("%s", no);
    if (n <= 2) printf ("%s", no);
    else printf ("%s", yes);

    return 0;
}

// @END_OF_SOURCE_CODE

Solution 3


// @BEGIN_OF_SOURCE_CODE
 
#include <cstdio>
 
using namespace std;
 
int main ()
{
    int n;
 
    scanf ("%d", &n);
 
    int remain = n - 2;
 
    if (remain >= 2 && remain % 2 == 0 ) printf ("YES\n");
    else printf ("NO\n");
 
    return 0;
}
 
// @END_OF_SOURCE_CODE

Solution 4


// @BEGIN_OF_SOURCE_CODE
 
#include <cstdio>
 
using namespace std;
 
int main ()
{
    int n;
 
    scanf ("%d", &n);
 
    printf ("%s\n", n >= 4 && n % 2 == 0 ? "YES" : "NO");
 
    return 0;
}
 
// @END_OF_SOURCE_CODE

Advertisements

One thought on “CF: 4A (Watermelon)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s