题目
问题描述
One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed w kilos. They rushed home, dying of thirst, and decided to divide the berry, however they faced a hard problem.
Pete and Billy are great fans of even numbers, that’s why they want to divide the watermelon in such a way that each of the two parts weighs even number of kilos, at the same time it is not obligatory that the parts are equal. The boys are extremely tired and want to start their meal as soon as possible, that’s why you should help them and find out, if they can divide the watermelon in the way they want. For sure, each of them should get a part of positive weight.
判断输入的正整数能否分成两个正偶数,能则输出YES,不能则输出NO。
输入格式
- 第1行是整数w。
输出格式
- 输出一行,满足条件输出YES,否则输出NO。
输入/输出例子
输入
8
输出
YES
提示
无
解题思路
分析
首先,能拆成两个偶数的一定是偶数。
(偶+偶=偶)
于是有人直接交。
if(n%2==0)puts("YES");
但是,还有一个二
2=1+1?
不对。
2=0+2?
也不对,0不是正偶数。
咋办呢? 特判
Code
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
if(n==2||n%2==1)
printf("NO");
else
printf("YES");
}