互关,题解
2026-08-17 20:23:50
发布于:广东
7阅读
0回复
0点赞
链接描述
先理解题目:
要把n个糖果平均分,且平均分为偶数
因为要平均分,所以n要为偶数
且平均分后也为偶数
所以代码可以这么写:
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
if(n%2==0&&n/2%2==0){
cout<<"YES";
}else cout<<"NO";
return 0;
}
但是,n %2 == 0 且 n /2 %2 ==0
不难得出n %4 == 0就行
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
if(n%4==0){
cout<<"YES";
}else cout<<"NO";
return 0;
}
这里空空如也



有帮助,赞一个