acmore 1510: ZZ love Cookies
2013-06-25 11:24
651 查看
1510: ZZ love Cookies
Time Limit: 1 Sec Memory Limit:64 MB
Submit: 228 Solved: 139
Submit
Status
Web Board
Description
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 dealif 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
11101 2 2 3 4 4 4 2 2 2Sample Output
18HINT
Source
2013ACM多校联合(4)_NUN解题思路:只要留下的饼干总数为偶数即可,若饼干总数为偶数,则可取走饼干数为偶数的任一包裹,否则可取走饼干数为奇数的任一包裹。
#include<stdio.h>
int main()
{
int sum,sum1,sum2;
int n;
int a[1002];
int i;
while(scanf("%d",&n)!=EOF)
{
sum=0;
sum1=0;
sum2=0;
int j=n;
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
sum+=a[i]; //统计总数
if(a[i]%2==0) //统计饼干为偶数个的包裹个数
sum1++;
else //统计饼干为奇数个的包裹个数
sum2++;
}
if(sum%2==0) //若总数为偶数,则可取走饼干数为偶数的任意包裹
sum=sum1;
else //若总数为奇数,则可取走饼干数为奇数的任意包裹
sum=sum2;
printf("%d\n",sum);
}
return 0;
}
相关文章推荐
- acmore 1510: ZZ love Cookies
- 多校联合(4) ZZ love Cookies
- Problem H: ZZ love Cookies
- 2013ACM多校联合(4)_NUN-ZZ love Cookies
- [zz] Love is a Fallacy 爱情是个谬误
- PieLove 之 数据分析帝.(ZZ)(is2120)
- JUnit Test Infected: Programmers Love Writing Tests (zz)
- GRE-LOVE-LIFE(zz)
- [zz暂时不清出出处]I LOVE U 的真正含义
- acmore 1503: ZZ买衣服
- (ZZ)From MYLOVE
- acmore 1503: ZZ买衣服
- [ZZ]采访与书摘:使用C#进行基于模型的软件测试和分析
- [zz]hadoop下运行多个SecondaryNameNode的配置
- Objective-C:为何使用ivar成员变量?Why would you use an ivar?[zz]
- A Taste of AOP from Solving Problems with OOP and Design Patterns (Part III) zz
- 设置cookies过期时间的几种方法 (总会用得着)12.6
- django设置cookies
- 【zz】FLV视频格式
- 细说Cookies