题解 | 小红取数

小红取数

https://www.nowcoder.com/practice/4391bfcde97f4220a63b43a645945e61

#include <iostream>
using namespace std;

int main() {
    int n;
    int quantity = 0;
    cin >> n;

    int num;
    while (cin >> num) {
	  // 如果有偶数参与乘法,则结果一定为偶数
	  // 所以,数出奇数的数量,就是答案
        if (num&1) {
            quantity += 1;
        }
    }

    if(quantity){
        cout << quantity;
    }else {
        cout << -1;
    }
        

}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

01-12 09:24
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务