NYOJ 464 Cookies
来源:互联网 发布:淘宝1920图片显示不全 编辑:程序博客网 时间:2024/06/17 01:10
Cookies
时间限制:1000 ms | 内存限制:65535 KB
难度:1
- 描述
- Olga came to visit the twins Anna and Maria and saw that they have many cookies. The cookies are distributed into bags. As there are many cookies, Olga decided that it's no big deal if she steals a bag. However, she doesn't want the sisters to quarrel because of nothing when they divide the cookies. That's why Olga wants to steal a bag with cookies so that the number of cookies in the remaining bags was even, that is, so that Anna and Maria could evenly divide it into two (even 0 remaining cookies will do, just as any other even number). How many ways there are to steal exactly one cookie bag so that the total number of cookies in the remaining bags was even?
- 输入
- The first line contains the only integer n (1 ≤ n ≤ 100) — the number of cookie bags Anna and Maria have. The second line contains n integers ai (1 ≤ ai ≤ 100) — the number of cookies in the i-th bag.Cases will be end with EOF.
- 输出
- Print in the only line the only number — the sought number of ways. If there are no such ways print 0.
- 样例输入
11101 2 2 3 4 4 4 2 2 2112 2 2 2 2 2 2 2 2 2 99
- 样例输出
181
思路:有若干袋饼干,每袋数量不同,要求拿走一袋,使总数量为偶数,求有多少种拿法?
如果总数量为偶数,拿走一个偶数袋,总数依然为偶数
如果总数量为奇数,拿走一个奇数袋,总数变为偶数
#include <stdio.h>int main(){int i,temp,n;while (scanf("%d",&n) != EOF){int even = 0,sum = 0;for (i=0; i<n; i++){scanf("%d",&temp);sum += temp;if (temp % 2 == 0){even++;}}if (sum % 2 == 0){printf("%d\n",even);}else{printf("%d\n",n - even);}}return 0;}
0 0
- NYOJ 464 Cookies
- NYOJ 464题 Cookies
- NYOJ 464 Cookies
- NYOJ 464 Cookies【简单题】
- 464 Cookies【水题】
- cookies
- Cookies
- Cookies
- Cookies
- Cookies
- Cookies
- cookies()
- Cookies
- Cookies
- Cookies
- Cookies
- Cookies
- cookies
- Single Image Dehazing Algorithm Based on Sky Region Segmentation(2013)
- 如何修改Eclipse的背景颜色
- UIAppearance的使用
- 对当前的学习生活工作的反思和总结
- QEMU, KVM, QEMU-KVM 和 Goldfish
- NYOJ 464 Cookies
- HDU 3579 Hello Kiki 解同余方程组
- Flex HBox VBox
- Linux系统改中文编码
- 如何在Android下使用JNI
- android保存Bitmap图片到指定文件夹示例
- iframe里面的页面调用父窗口,左右窗口js函数的方法
- eclipse
- SqlServer 重置自增主键