Codeforces 4A A. Watermelon (水)

Rating 800 总目录
题目链接入口
题目描述
一个体积为w(w为整数)的西瓜,要求判断该西瓜的体积能否分为两半,满足这两半体积均为偶数。
输入
输入整数w表示西瓜体积 ( 1 w 100 ) (1≤w≤100)
输出
如果该西瓜的体积能分为两半,且满足这两半体积均为偶数,则输出YES,反之则输出NO
案例
输入案例
8
输出案例
YES

题解:

  1. w w 不能 2 ≤2
  2. w w 一定为偶数,只有偶数才能拆成两个偶数
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define int ll
#define INF 0x3f3f3f3f
using namespace std;
int read()
{
	int w = 1, s = 0;
	char ch = getchar();
	while (ch < '0' || ch>'9') { if (ch == '-') w = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { s = s * 10 + ch - '0';    ch = getchar(); }
	return s * w;
}
//------------------------ 以上是我常用模板与刷题几乎无关 ------------------------//
signed main()
{
	int w;
	while (~scanf_s("%lld", &w))
	{
		if (w <= 2)
			printf("NO\n");
		else
		{
			if (w % 2 == 0)
				printf("YES\n");
			else
				printf("NO\n");
		}
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/m0_46272108/article/details/108178732