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;
}
0 comments:
Post a Comment