多校联合(4) ZZ love Cookies
2013-06-25 10:02
357 查看
题目链接:http://www.acmore.net/problem.php?id=1510
One day, ZZ came to visit her friend LL and DD and saw that they have many cookies. The cookies are distributed into bags, As there are many cookies, ZZ decided that it’s no big deal if she steals a bag. However,
she doesn’t want to her friends to quarrel because of nothing when they divide the cookies. That’s why ZZ wants to steal a bag with cookies so that the number of cookies in the remaining bags was even, that is, so that LL and DD could evenly divide into two
(even 0 remaining cookies will do, just as any other even number). How many ways there are to steal exactly one cookies bag so that the total number of cookies in the remaining bags was even?
in the i-th bag.
题目是一个简单的题目,只要统计奇数和偶数的个数,再把所有的数加起来SUM,看是奇数或偶数。
AC代码:
路途中。。。。。
One day, ZZ came to visit her friend LL and DD and saw that they have many cookies. The cookies are distributed into bags, As there are many cookies, ZZ decided that it’s no big deal if she steals a bag. However,
she doesn’t want to her friends to quarrel because of nothing when they divide the cookies. That’s why ZZ wants to steal a bag with cookies so that the number of cookies in the remaining bags was even, that is, so that LL and DD could evenly divide into two
(even 0 remaining cookies will do, just as any other even number). How many ways there are to steal exactly one cookies bag so that the total number of cookies in the remaining bags was even?
Input
The first line contains the only integer n (1 ≤ n ≤ 1000) — the number of cookie bags Anna and Maria have. The second line contains n integers ai (1 ≤ ai ≤ 1000) — the number of cookiesin the i-th bag.
Output
Print in the only line the only number — the sought number of ways. If there are no such ways print 0.Sample Input
1 1 10 1 2 2 3 4 4 4 2 2 2
Sample Output
1 8
题目是一个简单的题目,只要统计奇数和偶数的个数,再把所有的数加起来SUM,看是奇数或偶数。
AC代码:
#include<iostream> using namespace std; int main() { int n,i; int q[1008]; while(cin>>n && n) { int sum=0; int ant=0,ant1=0; for(i=0;i<n;i++) { cin>>q[i]; sum+=q[i]; if(q[i]%2 == 0) ant++; else ant1++; } if(sum%2 == 0) cout<<ant<<endl; else cout<<ant1<<endl; } return 0; }
路途中。。。。。
相关文章推荐
- 2013ACM多校联合(4)_NUN-ZZ love Cookies
- 2013多校联合4【Problem A: ZZ买衣服】
- 多校联合(4) ZZ买衣服
- 多校联合(4) ZZ买衣服
- 多校联合(4) ZZ的橱柜
- Problem H: ZZ love Cookies
- 多校联合(4) ZZ’s Fibonacci Problem
- acmore 1510: ZZ love Cookies
- 多校联合第4场: ZZ的计算器
- acmore 1510: ZZ love Cookies
- 2013多校联合训练第四场
- hdu 4642 fliping game 多校联合训练第四场
- 2013----多校联合5
- 2013多校联合8 1004 Terrorist’s destroy(hdu 4679)
- HDU/HDOJ 3875 Euclidean Algorithm 多校联合第四场
- HDOJ 5723 (2016多校联合训练 Training Contest 1) Abandoned country
- (ZZ)From MYLOVE
- [HDU5756] Boss Bo [2016 Multi-University Training Contest 3(2016多校联合训练3) E]
- 网络流hdu4888(多校联合)
- 陈老师的多校联合 20140809