Friday, August 11, 2017

First post of my new blog

  1. Problem: Watermelon


http://codeforces.com/problemset/problem/4/A
codeforces 4A(watermelon) solving in C++
Using modulus operator: 
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a;
    cin>>a;
    if(a==2)
    {
        cout<<"NO";

   
    else if(a%2==0)
    {
        cout<<"YES";
    }
    else
    {
        cout<<"NO";
    } return 0; } 
 Using bitwise operator:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a=1,b,c;
    cin>>b;
    if(b==2)
    {
        cout<<"NO"<<endl;
    }
    else
    {
        c=a&b;
        if(c==0)
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }
    }
    return 0;

}
Share:

0 comments: