A. Odds and Ends

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Where do odds begin, and where do they end? Where does hope emerge, and will they ever break?

Given an integer sequence a1, a2, ..., an of length n. Decide whether it is possible to divide it into an odd number of non-empty subsegments, the each of which has an odd length and begins and ends with odd numbers.

A subsegment is a contiguous slice of the whole sequence. For example, {3, 4, 5} and {1} are subsegments of sequence {1, 2, 3, 4, 5, 6}, while {1, 2, 4} and {7} are not.

Input

The first line of input contains a non-negative integer n (1 ≤ n ≤ 100) — the length of the sequence.

The second line contains n space-separated non-negative integers a1, a2, ..., an (0 ≤ ai ≤ 100) — the elements of the sequence.

Output

Output "Yes" if it's possible to fulfill the requirements, and "No" otherwise.

You can output each letter in any case (upper or lower).

Examples
input
3
1 3 5
output
Yes
input
5
1 0 1 5 1
output
Yes
input
3
4 3 1
output
No
input
4
3 9 9 3
output
No
Note

In the first example, divide the sequence into 1 subsegment: {1, 3, 5} and the requirements will be met.

In the second example, divide the sequence into 3 subsegments: {1, 0, 1}, {5}, {1}.

In the third example, one of the subsegments must start with 4 which is an even number, thus the requirements cannot be met.

In the fourth example, the sequence can be divided into 2 subsegments: {3, 9, 9}, {3}, but this is not a valid solution because 2 is an even number.

很惭愧,第一次打cf,只做出来这一道题。题意有点绕,大致就是问能不能把一个序列分成 奇数个 长度为奇数 且 首尾数字为奇数 的连续子序列。

当时做的时候,试了几个例子,发现如果n为偶数,无法同时满足个数和长度都为奇数,所以遇到n为偶数直接输出no。

n为奇数的时候,只要首尾两个数字是奇数就可以满足条件了。

附代码:

 1 #include <cstdio>
2 #include <cstring>
3 const int M = 111;
4 int nu[M];
5 int main(){
6 int n;
7 scanf("%d",&n);
8 for(int i=0;i<n;i++){
9 scanf("%d",&nu[i]);
10 }
11 if(nu[0]%2==0||nu[n-1]%2==0||n%2==0)
12 printf("No\n");
13 else printf("Yes\n");
14 return 0;
15 }

codeforce 849A的更多相关文章

  1. Codeforce - Street Lamps

    Bahosain is walking in a street of N blocks. Each block is either empty or has one lamp. If there is ...

  2. Codeforce Round #216 Div2

    e,还是写一下这次的codeforce吧...庆祝这个月的开始,看自己有能,b到什么样! cf的第二题,脑抽的交了错两次后过了pretest然后system的挂了..脑子里还有自己要挂的感觉,果然回头 ...

  3. Codeforce 水题报告(2)

    又水了一发Codeforce ,这次继续发发题解顺便给自己PKUSC攒攒人品吧 CodeForces 438C:The Child and Polygon: 描述:给出一个多边形,求三角剖分的方案数( ...

  4. codeforce 375_2_b_c

    codeforce 375_2 标签: 水题 好久没有打代码,竟然一场比赛两次卡在边界条件上....跪 b.题意很简单...纯模拟就可以了,开始忘记了当字符串结束的时候也要更新两个值,所以就错了 #i ...

  5. codeforce 367dev2_c dp

    codeforce 367dev2_c dp 标签: dp 题意: 你可以通过反转任意字符串,使得所给的所有字符串排列顺序为字典序,每次反转都有一定的代价,问你最小的代价 题解:水水的dp...仔细想 ...

  6. 三维dp&codeforce 369_2_C

    三维dp&codeforce 369_2_C 标签: dp codeforce 369_2_C 题意: 一排树,初始的时候有的有颜色,有的没有颜色,现在给没有颜色的树染色,给出n课树,用m种燃 ...

  7. 强连通分量&hdu_1269&Codeforce 369D

    强连通分量 标签: 图论 算法介绍 还记得割点割边算法吗.回顾一下,tarjan算法,dfs过程中记录当前点的时间戳,并通过它的子节点的low值更新它的low,low值是这个点不通过它的父亲节点最远可 ...

  8. 【树状数组】区间出现偶数次数的异或和(区间不同数的异或和)@ codeforce 703 D

    [树状数组]区间出现偶数次数的异或和(区间不同数的异或和)@ codeforce 703 D PROBLEM 题目描述 初始给定n个卡片拍成一排,其中第i个卡片上的数为x[i]. 有q个询问,每次询问 ...

  9. 解题报告:codeforce 7C Line

    codeforce 7C C. Line time limit per test1 second memory limit per test256 megabytes A line on the pl ...

随机推荐

  1. ABP vNext 实现租户Id自动赋值插入

    背景 在使用ABP vNext过程中,因为我们的用户体系庞大,所以一直与其他业务同时开发,在开发其他业务模块时,我们一直存在着误区:认为ABP vNext 自动处理了数据新增时的租户Id(Tenant ...

  2. protoc-gen-validate (PGV)

    https://github.com/envoyproxy/protoc-gen-validate This project is currently in alpha. The API should ...

  3. JavaScript代码是怎么执行的?

    前言 众所周知,JavaScript是单线程语言.所以JavaScript是按顺序执行的! 先编译再执行 变量提升 请看下面的例子: console.log(cat) catName("Ch ...

  4. vim 行号的显示与隐藏

    通常我们在使用vim编辑器的时候,需要显示和隐藏行号 隐藏行号: 1.首先我们vim   1.txt   (进入我们编辑的文档),如下,此时是显示行号的 2.按一下esc键,并输入:(冒号),完成效果 ...

  5. Prometheus+Grafana通过kafka_exporter监控kafka

    Prometheus+Grafana通过kafka_exporter监控kafka 一.暴露 kafka-metric 方式 二.jmx_exporter方式 2.1 下载jmx_prometheus ...

  6. 利用Javascript制作网页特效(时间特效)

    在网页中经常可以看到各种各样的动态时间显示,在网页中合理地使用时间可以增加网页的时效感. 显示当前时间 getHours().getMinutes().getSeconds()分别获得当前小时数.当前 ...

  7. JavaScript——事件

    事件:是由访问Web页面的用户引起一系列操作. 事件的作用:用于浏览器和用户的交互 以下代码为相关试验代码: HTML事件: <script type="text/javascript ...

  8. 码一次前后台post请求交互,以及接口的使用,json数据格式的传递

    近几天,公司疯狂加班,然后补做了很多功能,很多东西虽然是自己熟悉的,但是却不会上手,动手实践能力仍需加强,对此对一些代码记录,留待学习和总结. 简单描述功能 具体实现 前台JSP.JS.后台actio ...

  9. Java 高并发 解决方案

    1.HTML静态化 2.图片服务器分离 3.数据库集群和库表散列 4.缓存 5.镜像 6.负载均衡 1)硬件四层交换 2)软件四层交换 一:高并发高负载类网站关注点之数据库 二:高并发高负载网站的系统 ...

  10. 3.centos 7执行service iptables save报错问题

    1.报错 [root@localhost ~]# service iptables save The service command supports only basic LSB actions ( ...