A. Watermelon西瓜 (time limit per test:1 second, memory limit per test :64 megabytes, input:standard input,output:standard output)
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.
Input:The first (and the only) input line contains integer number w (1 ≤ w ≤ 100) — the weight of the watermelon bought by the boys. Output:Print YES, if the boys can divide the watermelon into two parts, each of them weighing even number of kilos; and NO in the opposite case. Examples:Input:8 -> Output:YES Note:For example, the boys can divide the watermelon into two parts of 2 and 6 kilos respectively分别 (another variant 变体 — two parts of 4 and 4 kilos). 读题:一个西瓜,两个好朋友分西瓜,要求这个西瓜质量w在(1,100)范围内,他们分的时候要求将这个西瓜切成两份且两份的质量为偶数 思考:这个西瓜质量至少为4,否则无法被切分成两个偶数值,则:w/2>1,因为偶+偶=偶,所以w也是偶数,则w%2==0#include<iostream> #include<iomanip> #include<cmath> using namespace std; int main(){ int w,a,b; cin>>w; if(w/2>1 && w%2==0){ cout<<"YES"<<endl; }else{ cout<<"NO"<<endl; } }
标签:西瓜,divide,第一天,C++,kilos,算法,parts,watermelon,they From: https://www.cnblogs.com/AlbertKs220111/p/17896944.html