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

Copy
3
1 3 5
output

Copy
Yes
input

Copy
5
1 0 1 5 1
output

Copy
Yes
input

Copy
3
4 3 1
output

Copy
No
input

Copy
4
3 9 9 3
output

Copy
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.

算法:思维

题解:如果n是奇数,并且 a[1] 和 a[n] 也是奇数,那么就输出Yes,否则No。

#include <iostream>
#include <cstdio>
#include <algorithm> using namespace std; typedef long long ll; #define INF 0x3f3f3f3f
const int maxn = 1e5+; ll a[maxn];
int n; int main() {
scanf("%d", &n);
for(int i = ; i <= n; i++) {
cin >> a[i];
}
if(n % == && a[] % == && a[n] % == ) {
printf("Yes\n");
} else {
printf("No\n");
}
return ;
}

A. Odds and Ends(思维)的更多相关文章

  1. Codeforces 849A:Odds and Ends(思维)

    A. Odds and Ends Where do odds begin, and where do they end? Where does hope emerge, and will they e ...

  2. 【Codeforces Round #431 (Div. 2) A】Odds and Ends

    [链接]点击打开链接 [题意] 让你把一个数组分成奇数个部分. 且每个部分的长度都是奇数. [题解] 很简单的脑洞题. 开头和结尾一定要为奇数,然后 n为奇数的话,就选整个数组咯. n为偶数的话,不能 ...

  3. 【Codeforces Round 431 (Div. 2) A B C D E五个题】

    先给出比赛地址啦,感觉这场比赛思维考察非常灵活而美妙. A. Odds and Ends ·述大意:      输入n(n<=100)表示长度为n的序列,接下来输入这个序列.询问是否可以将序列划 ...

  4. Codeforces Round #431 (Div. 2)

    A. Odds and Ends Where do odds begin, and where do they end? Where does hope emerge, and will they e ...

  5. POJ3160 Father Christmas flymouse[强连通分量 缩点 DP]

    Father Christmas flymouse Time Limit: 1000MS   Memory Limit: 131072K Total Submissions: 3241   Accep ...

  6. Father Christmas flymouse--POJ3160Tarjan

    Father Christmas flymouse Time Limit: 1000MS Memory Limit: 131072K Description After retirement as c ...

  7. <老友记>学习笔记

    这是六个人的故事,从不服输而又有强烈控制欲的monica,未经世事的千金大小姐rachel,正直又专情的ross,幽默风趣的chandle,古怪迷人的phoebe,花心天真的joey——六个好友之间的 ...

  8. 分享O'Reilly最新C语言指针数据

    1.推荐书名 Understanding.and.Using.C.Pointers.pdf 2. 本书目录 Table of Content Chapter 1. Introduction Chapt ...

  9. Fast-paced Multiplayer

    http://www.gabrielgambetta.com/fpm1.html —————————————————————————————————————————————————————— Fast ...

随机推荐

  1. JDBC 24homework

    编写程序: 1. 创建商品信息表Goods(包含编号Code.名称Name.数量Number.单价Price) 2. 设计程序流程,由用户选择:插入.删除.修改.查询 程序效果如下: (1)根据提示输 ...

  2. 洛谷UVA11987Almost Union-Find题解--并查集的删除

    题目链接 https://www.luogu.org/problemnew/show/UVA11987 分析 分析下操作发现就是加了个删除操作的并查集,怎么做删除操作呢. 我们用一个\(id[]\)记 ...

  3. O035、Nova Suspend / Rescue 操作详解

    参考https://www.cnblogs.com/CloudMan6/p/5503501.html   Suspend / Resume   有时候需要长时间暂停 instance , 可以通过 S ...

  4. java 计算中位数方法

    最近工作需要 要求把python的代码写成java版本,python中有一个np.median()求中位数的方法,java决定手写一个 先说说什么是中位数: 中位数就是中间的那个数, 如果一个集合是奇 ...

  5. VMwarevSphere Client 链接 vCenter Server中的主机,开启虚拟机提示:在主机当前连接状况下不允许执行该操作

    VMwarevSphere Client 链接 vCenter Server中的主机,开启虚拟机提示:在主机当前连接状况下不允许执行该操作很多原因都可以导致该问题出现,例如 vCenter Serve ...

  6. C++ void*解惑

    最近遇到void *的问题无法解决,发现再也无法逃避了(以前都是采取悄悄绕过原则),于是我决定直面它. 在哪遇到了? 线程创建函数pthread_create()的最后一个参数void *arg,嗯? ...

  7. 第十章、sys模块

    目录 第十章.sys模块 第十章.sys模块 方法 详解 sys.argv 命令行参数List,第一个元素是程序本身路径 sys.modules.keys() 返回所有已经导入的模块列表 sys.ex ...

  8. 1、Bash Shell

    一.什么是Bash shell BashShell是一个命令解释器,它在操作系统的最外层,负责用户程序与内核进行交互操作的一种接口,将用户输入的命令翻译给操作系统,并将处理后的结果输出至屏幕. 当我们 ...

  9. 使用 Eclipse 构建的时候会出现 run as 中没有 maven package 选项

    注:该方法来自我学习时别人分享的出现问题的解决方法,并没有亲自测试,仅供参考 是因为建的是普通 java 工程,需要把它转换成 maven project. 1.右键工程--maven--Disabl ...

  10. 牛客小白月赛12 C 华华给月月出题 (积性函数,线性筛)

    链接:https://ac.nowcoder.com/acm/contest/392/C 来源:牛客网 华华给月月出题 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 131072K, ...