Codeforces 849A Odds and Ends

其实只要判断头尾是不是奇数,以及n是否为奇数即可。

因为把序列分成奇数个奇数段,长度必然为奇数。

如果头尾有一个不是奇数,那么必然不可以。

反之则一定可以,所以O( 1 )就好了。

我的做法太垃圾了。。

#include<cstdio>
int n;
int main(){
    scanf("%d",&n);
    if(n%2==0){
        puts("No");
        return 0;
    }
    int ok=1;
    for(int i=1;i<=n;i++){
        int x;
        scanf("%d",&x);
        if(x%2==0){
            if(i==1){
                puts("No");return 0;
            }
            if(i==n){
                puts("No");return 0;
            }
            ok=0;
        }
        if(x%2==1) ok=1;
    }
    puts("Yes");
    return 0;
}
时间: 2024-08-19 09:26:18

Codeforces 849A Odds and Ends的相关文章

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 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 subsegmen

&lt;老友记&gt;学习笔记

这是六个人的故事,从不服输而又有强烈控制欲的monica,未经世事的千金大小姐rachel,正直又专情的ross,幽默风趣的chandle,古怪迷人的phoebe,花心天真的joey——六个好友之间的情路坎坷,事业成败和生活中的喜怒哀乐,无时无刻不牵动着彼此的心,而正是正平凡的点点滴滴,却成为最令人感动与留恋的东西. 人物:1.瑞秋•格林(RACHEL GREENE)由珍妮佛•安妮斯顿(Jennifer Aniston)扮演 瑞秋是莫妮卡的高中同学,在与牙医未婚夫的婚礼上脱逃至莫妮卡处. 2.罗

Python 2.7.8 学习笔记(001)python manuals/the python tutorial

从今天开始学python, python有点意思,第一感觉界面和matlab有点像. 手头没有什么资料,就从安装好了的一个python 2.7.8,里面有个英文版的manual,那就只好从这里开始吧,为什么不是中文版的呢??那就边看边翻译吧. python漫游指南:python是一种简单易学功能强大的编程语言.它有高效的数据结构和简单但有效的面向对象编程方法.python优雅的语法和动态拼写以及解释特性,使得它在许多平台上成为一种理想的脚本语言和快速程序开发工具. python的解释器和扩展标准

POJ 3160 Father Christmas flymouse

Father Christmas flymouse Time Limit: 1000ms Memory Limit: 131072KB This problem will be judged on PKU. Original ID: 316064-bit integer IO format: %lld      Java class name: Main After retirement as contestant from WHU ACM Team, flymouse volunteered

一周水题集锦 2017 8.28

CF Round 431 A. Odds and Ends 解题思路:长度为奇数,开头奇数,结尾奇数. CS Academy Round 44 Frequent Numbers 解题思路:需要吗??? CS Academy Round 44 Square Cover 解题思路:对于每个点,如果未访问并且该数字未出现过就向右向下延伸,之后是否包围了正方形以及其中数字是否全部相等.标记该点以及该数字.出现未访问过的点但是数字访问过也不满足. HDU 6182 A Math Problem 解题思路:

awesome-qt

Awesome Qt  A curated list of awesome tools, libraries, and resources for the Qt framework. Qt is a powerful cross-platform application development framework, for use primarily (but not exclusively) in C++. It's great for GUI applications, but can be

CNPC海外操作人员英语日常用语900句

一.Greetings 问候语1. Hello! / Hi! 你好!2. Good morning / afternoon / evening! 早晨(下午/晚上)好!3. I’m Kathy King. 我是凯西•金.4. Are you Peter Smith? 你是彼得•史密斯吗?5. Yes, I am. / No, I’m not. 是,我是./ 不,我不是.6. How are you? 你好吗?7. Fine, thanks. And you? 很好,谢谢,你呢?8. I’m fi

KVM and CentOS-6

CentOS 6 has native availability of KVM virtualization support and tools in the base distribution. Dell provides two whitepapers about how to use KVM in CentOS 6, part 1 and part 2. See the meta packages contained in: # yum grouplist | grep -i virt 1

Git手册

GitUserManualChinese - Robin Wiki GitUserManualChinese Git 用户手册(1.5.3 及后续版本适用) 翻译: 罗峥嵘 (Robin Steven) < [email protected] > 英文版本: http://www.kernel.org/pub/software/scm/git/docs/user-manual.html Contents Preface 前言 Chapter 1. Repositories and Branch