A8315 | Cookies
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $a_{i}$ ( $1<=a_{i}<=100$ ) — the number of cookies in the $i$ -th bag.
输出格式
Print in the only line the only number — the sought number of ways. If there are no such ways print 0.
输入输出样例
输入 #1
1 1
输出 #1
1
输入 #2
10 1 2 2 3 4 4 4 2 2 2
输出 #2
8
输入 #3
11 2 2 2 2 2 2 2 2 2 2 99
输出 #3
1
In the first sample Olga should take the only bag so that the twins ended up with the even number of cookies.
In the second sample Olga can take any of five bags with two cookies or any of three bags with four cookies — $5+3=8$ ways in total.
In the third sample, no matter which bag with two cookies Olga chooses, the twins are left with $2*9+99=117$ cookies. Thus, Olga has only one option: to take the bag with $99$ cookies.
In the second sample Olga can take any of five bags with two cookies or any of three bags with four cookies — $5+3=8$ ways in total.
In the third sample, no matter which bag with two cookies Olga chooses, the twins are left with $2*9+99=117$ cookies. Thus, Olga has only one option: to take the bag with $99$ cookies.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted