A. Cookies
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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?

Input

The first line contains the only integer n (1 ≤ n ≤ 100)
— the number of cookie bags Anna and Maria have. The second line contains nintegers ai (1 ≤ ai ≤ 100)
— the number of cookies in 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 test(s)
input
  1. 1
  2. 1
output
  1. 1
input
  1. 10
  2. 1 2 2 3 4 4 4 2 2 2
output
  1. 8
input
  1. 11
  2. 2 2 2 2 2 2 2 2 2 2 99
output
  1. 1
  1. 题意:从一个数列中任取出一个数,使剩下的数的和是偶数,问共同拥有多少种取法。
  1. On*n)算法 ,非常暴力。
  2.  
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <cstdio>
  4. #include <cstring>
  5. #include <string>
  6. #include <vector>
  7. using namespace std;
  8. #define LL long long
  9. int main()
  10. {
  11. 	int a[110],i,j,n,sum;
  12. 	while(scanf("%d",&n)!=EOF)
  13. 	{
  14. 		int cnt=0;
  15. 		for(i=0;i<n;i++)
  16. 			scanf("%d",a+i);
  17. 		for(i=0;i<n;i++)
  18. 		{
  19. 			sum=0;
  20. 			for(j=0;j<n;j++)
  21. 				if(j!=i)
  22. 					sum+=a[j];
  23. 			if(sum%2==0)
  24. 				cnt++;
  25. 		}
  26. 		printf("%d\n",cnt);
  27. 	}
  28. 	return 0;
  29. }

Codeforces 129A-Cookies(暴力)的更多相关文章

  1. Karen and Game CodeForces - 816C (暴力+构造)

    On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as fo ...

  2. CodeForces 1099F - Cookies - [DFS+博弈+线段树]

    题目链接:https://codeforces.com/problemset/problem/1099/F Mitya and Vasya are playing an interesting gam ...

  3. Chladni Figure CodeForces - 1162D (暴力,真香啊~)

    Chladni Figure CodeForces - 1162D Inaka has a disc, the circumference of which is nn units. The circ ...

  4. Array and Segments (Easy version) CodeForces - 1108E1 (暴力枚举)

    The only difference between easy and hard versions is a number of elements in the array. You are giv ...

  5. CodeForces - 589D(暴力+模拟)

    题目链接:http://codeforces.com/problemset/problem/589/D 题目大意:给出n个人行走的开始时刻,开始时间和结束时间,求每个人分别能跟多少人相遇打招呼(每两人 ...

  6. CodeForces - 589B(暴力)

    题目链接:http://codeforces.com/problemset/problem/589/B 题目大意:告诉你n 个矩形,知道矩形的长度和宽度(长和宽可以互换),每个矩形的长度可以剪掉一部分 ...

  7. CodeForces - 589B(暴力+排序)

    Dasha decided to bake a big and tasty layer cake. In order to do that she went shopping and bought n ...

  8. Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem F (Codeforces 831F) - 数论 - 暴力

    题目传送门 传送门I 传送门II 传送门III 题目大意 求一个满足$d\sum_{i = 1}^{n} \left \lceil \frac{a_i}{d} \right \rceil - \sum ...

  9. CodeForces 156A Message(暴力)

    A. Message time limit per test 2 seconds memory limit per test 256 megabytes input standard input ou ...

随机推荐

  1. 记intel杯比赛中各种bug与debug【其三】:intel chainer的安装与使用

    现在在训练模型,闲着来写一篇 顺着这篇文章,顺利安装上intel chainer 再次感谢 大黄老鼠 intel chainer 使用 头一次使用chainer,本以为又入了一个大坑,实际尝试感觉非常 ...

  2. Dia Diagram Editor(流程图、UML)免费开源绘图软件

    近期工作各种繁忙,导致很少分享自己喜欢和常用的一些工具,今天有点时间再次给各位喜欢开源的小伙伴介绍一个好用.免费.开源的软件Dia Diagram Editor. 首先给大家看看这个软件的主界面吧! ...

  3. Linux 常用命令:系统状态篇

    前言 Linux常用命令中,有些命令可以用于查看系统的状态,通过了解系统当前的状态,能够帮助我们更好地维护系统或定位问题.本文就简单介绍一下这些命令. 1. 查看系统运行时间--uptime 有时候我 ...

  4. ArcGIS api for javascript——地图配置-增加标注到滑动器

    描述 ArcGISTiledMapServiceLayer,这意味着图层有一个在明确的比例的预先渲染的地图切片的cache.能够从tileInfo属性获得图层的的缓存比例数组.这是本例中标注如何被得到 ...

  5. Liquibase简介(1)

    Liquibase是一个用于跟踪.管理和应用数据库变化的开源的数据库重构工具.它将所有数据库的变化(包括结构和数据)都保存在XML文件中,便于版本控制. Liquibase具备如下特性: * 不依赖于 ...

  6. BEGINNING SHAREPOINT&#174; 2013 DEVELOPMENT 第9章节--client对象模型和REST APIs概览 JavaScript

    BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第9章节--client对象模型和REST APIs概览  JavaScript         与托管.NETclien ...

  7. QlikView随意改变图例的位置

    组里面花了大价钱请人设计了一套UI的solution,只是是以站点思路设计的报表样式,可是该报表UI设计团队本身因为没有QlikView的背景,因此设计出来的报表不知道能不能再QlikView中实现, ...

  8. 线程池系列一:线程池作用及Executors方法讲解

    线程池的作用: 线程池作用就是限制系统中执行线程的数量.     根据系统的环境情况,可以自动或手动设置线程数量,达到运行的最佳效果:少了浪费了系统资源,多了造成系统拥挤效率不高.用线程池控制线程数量 ...

  9. poj--1237--Drainage Ditches(最大流)

    Drainage Ditches Time Limit: 1000MS   Memory Limit: 10000KB   64bit IO Format: %I64d & %I64u Sub ...

  10. DevExpress Report打印边距越界问题

    DevExpress  Report Print的时候,出现这样的问题:one or more margins are set outside the printable area of the pa ...