Codeforeces 849A Odds and Ends

2023-12-28 01:18
文章标签 ends codeforeces 849a odds

本文主要是介绍Codeforeces 849A Odds and Ends,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

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.

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

第二次打cf。看到第一题就懵了。无从下手的感觉。

想了快一个小时吧,凑出一个dfs来,交了就pretest accept了。
后来听别人说样例只有一个1  1。。。
然后赛后重测。。就wa了 orz
惨遭爆零啊太惨了。。
果然脑洞题不适合我 (可能是做题太少了)
题意:一个序列,让你把它分成奇数个区间,每个区间长度是奇数,并要求以奇数开始和结束。
看了题解意识到,奇数*奇数==奇数。
所以长度必为奇数,长度为奇数,只要头和尾都是奇数就可以了。。

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstring>
#include <queue>
#include <string>
#define N 1e5+10
using namespace std;
int loc[110],cnt=0,len=0;
int main()
{int n,flag=1,t;cin>>n;if(n%2)for(int i=0;i<n;i++){cin>>t;if(i==0||i==n-1)if(t%2==0){flag=0;break;}}else flag=0;if(flag)cout<<"Yes"<<endl;else cout<<"No"<<endl;return 0;
}


这篇关于Codeforeces 849A Odds and Ends的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/544757

相关文章

【CodeForeces】【#290_(div.2)_C】拓扑排序

题意: 给出n个单词,已知单词们已经按“字典序”递增排好。问题是,这个“字典序”并不是传统的abc,而是26个字母的未知排列。你需要做的是求出这个排列。当然有一些重复的特殊情况之类的,就不多说了。 思路: 拓扑排序,将26个字母视作26个点,根据给出的单词表,可以从中处理出一些数据,即“某字母a小于某字母b”,然后就在a到b建一条边。建好图之后拓扑排序得到答案。 遗憾的是,题目有cheat

ends,flush,endl 用法区别

ends函数 终止字符串flush函数 刷新缓冲区endl函数 终止一行并刷新缓冲区#include <iostream>int main(){using namespace std;cout << "a" ;cout << "b" <<ends;cout << "c" <<endl;cout << "e" << flush;cout << "f" << flush;cout << "g"

C++ 字符串处理3-实现starts_with和ends_with的字符串判断功能

1. 关键词2. C++20及之后3. C++20之前 3.1. strutil.h3.2. strutil.cpp3.3. 测试代码3.4. 运行结果3.5. 源码地址 1. 关键词 C++ 字符串处理 starts_with ends_with std::string 跨平台 2. C++20及之后 C++20标准开始,STL已经提供了starts_with和ends_with函数,

【Unity游戏制作】地精寻宝Gnome‘s Well That Ends Well卷轴动作游戏【一】场景搭建

👨‍💻个人主页:@元宇宙-秩沅 👨‍💻 hallo 欢迎 点赞👍 收藏⭐ 留言📝 加关注✅! 👨‍💻 本文由 秩沅 原创 👨‍💻 专栏交流🧧🟥Unity100个实战基础✨🎁🟦 Unity100个精华一记✨🎁🟩 Unity50个demo案例教程✨🎁🟨 Unity100个精华细节BUG✨🎁 文章目录 ⭐前言⭐🎶(==1==) 开

vue2中npm i报错gyp info it worked if it ends with ok

当我拿到一个老的vue2项目,怎么也起不起来,后来找到报错原因,如上图所示,可以看到报错的path是node-sass,那么就猜想应该是sass版本和node版本不匹配。  于是我查看了我的node版本是16+ 而sass版本是下图所示,版本有点低 此时根据对照表,修改sass版本即可 ,也可以选择降低node版本,但我认为直接修改sass版本更方便~     sass-

poj 2738 Two Ends

题目:http://poj.org/problem?id=2738  没什么好说的,记忆化搜索···   #include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int a[1005];int dp[1005][1005];int max(int i,int j){return

gyp info it worked if it ends with ok

😭当一个项目初始化的时候,一般通过npm install 或 yarn安装npm模块包,假如库里边使用了sass作为项目css预处理器,那么恭喜你很可能入了这个坑。 原因 `node-sass` 这个npm包需要依赖gyp、node-gyp、python等环境和库的支持,但在加载这些包的时候由于境内网络墙的原因导致下载失败从而无法正确执行,还有可能是这些库执行某个操作的时候依

npm install 安装报错 gyp info it worked if it ends with ok

话不多说,先上报错截图 报错截图 1.可能原因 node 和 node-sass版本冲突,或者是node-sass安装不了即git的网址访问不了 版本对应表 数据来源 GitHub - sass/node-sass: Node.js bindings to libsass 版本查询 查看node版本和npm 版本:   node -vnpm -v 2.解决办法

npm install安装依赖错误:gyp info it worked if it ends with ok的问题

开了新项目,安装依赖的时候发现抱错,网上很多解决办法,原因node和node-sass版本冲突 报错信息 err gyp info it worked if it ends with ok err gyp....... err gyp....... err gyp....... err gyp....... err ver....... 这里推荐最简单粗暴的,卸载node,去官

[踩坑吐血解决]npm ERR! gyp info it worked if it ends with oknpm ERR! gyp verb cli

项目场景: 今天从GitHub上拉了一个vue前端项目,也就是人人开源的前端项目。在进行npm install的时候给我报了一大堆错误 人人开源前端地址:https://gitee.com/renrenio/renren-fast-vue.git 在install的时候报的错误:  一开始,清理缓存,去官网看一下node和npm的对应版本是否正确,以下是node官网上node和np