群众想要吃瓜,于是给你一个瓜让你切,但是作为考验 告诉你西瓜的重量,问你能否将这个西瓜分成两部分,每个部分都是偶数。
吃瓜群众
https://ac.nowcoder.com/acm/problem/22014
开始的时候一直执着于<abbr title="%4==0">这样</abbr>
#include<stdio.h> int main(){ int weight; scanf("%d",&weight); if(weight%4==0){ printf("YES, you can divide the watermelon into two even parts."); }else{ printf("NO, you can't divide the watermelon into two even parts."); } }
最后发现,原题是不要两边对半分的,没有考虑到。所以其实除了2,只需要 %2
就足够啦。
#include<stdio.h> int main(){ int weight; scanf("%d",&weight); if (weight%2==0&&weight!=2){ printf("YES, you can divide the watermelon into two even parts."); }else{ printf("NO, you can't divide the watermelon into two even parts."); } }