A. Odds and Ends(思维)
1 second
256 megabytes
standard input
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.
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 "Yes" if it's possible to fulfill the requirements, and "No" otherwise.
You can output each letter in any case (upper or lower).
3
1 3 5
Yes
5
1 0 1 5 1
Yes
3
4 3 1
No
4
3 9 9 3
No
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(思维)的更多相关文章
- 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 ...
- 【Codeforces Round #431 (Div. 2) A】Odds and Ends
[链接]点击打开链接 [题意] 让你把一个数组分成奇数个部分. 且每个部分的长度都是奇数. [题解] 很简单的脑洞题. 开头和结尾一定要为奇数,然后 n为奇数的话,就选整个数组咯. n为偶数的话,不能 ...
- 【Codeforces Round 431 (Div. 2) A B C D E五个题】
先给出比赛地址啦,感觉这场比赛思维考察非常灵活而美妙. A. Odds and Ends ·述大意: 输入n(n<=100)表示长度为n的序列,接下来输入这个序列.询问是否可以将序列划 ...
- 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 ...
- POJ3160 Father Christmas flymouse[强连通分量 缩点 DP]
Father Christmas flymouse Time Limit: 1000MS Memory Limit: 131072K Total Submissions: 3241 Accep ...
- Father Christmas flymouse--POJ3160Tarjan
Father Christmas flymouse Time Limit: 1000MS Memory Limit: 131072K Description After retirement as c ...
- <老友记>学习笔记
这是六个人的故事,从不服输而又有强烈控制欲的monica,未经世事的千金大小姐rachel,正直又专情的ross,幽默风趣的chandle,古怪迷人的phoebe,花心天真的joey——六个好友之间的 ...
- 分享O'Reilly最新C语言指针数据
1.推荐书名 Understanding.and.Using.C.Pointers.pdf 2. 本书目录 Table of Content Chapter 1. Introduction Chapt ...
- Fast-paced Multiplayer
http://www.gabrielgambetta.com/fpm1.html —————————————————————————————————————————————————————— Fast ...
随机推荐
- 【IntelliJ IDEA】从资源文件读取出来就中文乱码的解决方法
在application.properties资源文件中设置两个自定义的属性以及属性值: com.sxd.name = "德玛西亚" com.sxd.want = "王者 ...
- .Net面试题二
谈谈创建线程的方式 1.列举.Net页面之间传值的方式 2..Net中aspx页面从客户端浏览器开始请求到服务器返回响应所经历的过程 CLR主要运行过程 ASP.NET运行管道所有事件 3.如何理解委 ...
- -bash: fork: retry: 没有子进程
今天遇到一个问题 -bash: fork: retry: 没有子进程 解决方法 设置各linux 用户的最大进程数,下面我把某linux用户的最大进程数设为10000个: ulimit -u 10 ...
- Sublime Text 3配置浏览默认路径为localhost
1.在 Sublime Text 3 中,安装 SideBarEnhancements 侧边栏增强插件.(注意:安装插件之前需要安装包管理工具,参考这里) 2.SideBarEnhancements ...
- SNI功能在NetScaler上的实现
SNI功能在NetScaler上的实现 来源 https://raynorli.com/2018/09/11/sni-on-netscaler/ 现网中经常是一台主机上运行多个Web站点,如果启用了 ...
- git commit报错解决,绕过代码检查
上一个项目用的svn,新项目用了git,很开心,终于学习了git了,本以为把git都学会了,但是还是遇到了一个不在自己学习的知识点范围内的问题,最后是同事帮忙解决的. 问题:第一次代码commit的时 ...
- 如何使用koa搭建一个简单服务
1.首先检测是否已经有node环境? 把Windows的黑窗体的命令行工具调用出来 敲击命令行node -v , 然后,就可以看到这个打印出了一个版本号,这就证明我们的node.js已经是安装 ...
- css 单位
CSS 有几个不同的单位用于表示长度. 一些设置 CSS 长度的属性有 width, margin, padding, font-size, border-width, 等. 长度有一个数字和单位组成 ...
- Nginx作为静态资源web服务之缓存原理
Nginx作为静态资源web服务之缓存原理 大致理一下http浏览器缓存原理: 浏览器第一次请求服务器,此时浏览器肯定没有缓存,则直接调用服务器端,服务器在返回的信息的信息头中添加 ETag和Last ...
- Delphi 图形组件(Shape)
樊伟胜