Codeforeces 849A Odds and Ends
来源:互联网 发布:优化产业结构什么意思 编辑:程序博客网 时间:2024/05/05 07:12
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).
31 3 5
Yes
51 0 1 5 1
Yes
34 3 1
No
43 9 9 3
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+10using 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
- A. Odds and Ends
- codeforces 849A A.Odds and Ends
- Codeforces 849 A Odds and Ends
- CodeForces-849A Odds and Ends
- codeforces 849A Odds and Ends
- Codeforces 849A. Odds and Ends 结论题,水题
- odds and ends
- cfA. Odds and Ends
- Codeforces849A Odds and Ends
- Odds and Ends
- Codeforces Round #431 (Div. 2) 849A Odds and Ends(思维)
- Codeforces Round #431 (Div. 2) A Odds and Ends
- Codeforces Round #431 (Div. 2) A. Odds and Ends
- Codeforces Round #431 (Div. 2) A. Odds and Ends 题解
- CodeForces 431# div.2 A Odds and Ends 暴力 贪心
- Codeforces Round #431 (Div. 2) A. Odds and Ends(找规律)
- A. Odds and Ends Codeforces Round #431 (Div. 2)(水题)
- leetcode 27 removeElement
- Java I/O流总结
- 工件调度
- BZOJ2716: [Violet 3]天使玩偶(CDQ分治)
- OSGI(1)_入门
- Codeforeces 849A Odds and Ends
- rman restore controlfile
- (二)依赖项属性
- 签到
- JS正则表达式验证数字
- sql查询汉字首字母
- μCOS 系列专题—内核结构(1)
- 如何用CSS画三角形
- 单点登录原理与简单实现