Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given n numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — to check his answers, he needs a program that among the given n numbers finds one that is different in evenness.

Input

The first line contains integer n (3 ≤ n ≤ 100) — amount of numbers in the task. The second line contains n space-separated natural numbers, not exceeding 100. It is guaranteed, that exactly one of these numbers differs from the others in evenness.

Output

Output index of number that differs from the others in evenness. Numbers are numbered from 1 in the input order.

Examples
input
5
2 4 7 8 10
output
3
input
4
1 2 1 1
output
2

题解:一组数只有一个奇数或者偶数,输出它的位置.
 #include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
const int N=;
const int mod=1e9+;
int a[N];
int main()
{
int n;
while(cin>>n){
int i,flag1,flag2,sum1=,sum2=;
for(i=;i<n;i++){
cin>>a[i];
if(a[i]%==){
flag2=i+;
sum2++;
}
else {
flag1=i+;
sum1++;
}
}
if(sum1>&&sum2>){
if(sum1==) cout<<flag1<<endl;
else cout<<flag2<<endl;
}
}
return ;
}
 

Codeforce 25A - IQ test (唯一奇偶)的更多相关文章

  1. Codeforce 287A - IQ Test (模拟)

    In the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the ...

  2. 即时通信系统Openfire分析之五:会话管理

    什么是会话? A拨了B的电话 电话接通 A问道:Are you OK? B回复:I have a bug! A挂了电话 这整个过程就是会话. 会话(Session)是一个客户与服务器之间的不中断的请求 ...

  3. Codeforces Beta Round #25 (Div. 2 Only) A. IQ test【双标记/求给定数中唯一的奇数或偶数】

    A. IQ test time limit per test 2 seconds memory limit per test 256 megabytes input standard input ou ...

  4. Codeforce 215 div1

    C 把每个qi看成点,则问题转化为:求一个最大的k,遍历k个点的完全图需要的最小步数+1不超过n, (这里+1的原因是把起点加进去) 讨论k的奇偶: k为奇数,每个点度数为偶数,这是一个欧拉回路,步数 ...

  5. Codeforce 水题报告(2)

    又水了一发Codeforce ,这次继续发发题解顺便给自己PKUSC攒攒人品吧 CodeForces 438C:The Child and Polygon: 描述:给出一个多边形,求三角剖分的方案数( ...

  6. 强连通分量&hdu_1269&Codeforce 369D

    强连通分量 标签: 图论 算法介绍 还记得割点割边算法吗.回顾一下,tarjan算法,dfs过程中记录当前点的时间戳,并通过它的子节点的low值更新它的low,low值是这个点不通过它的父亲节点最远可 ...

  7. Sybase IQ使用过程中注意事项

    Sybase IQ使用过程中注意事项 1,字母大小写比对不敏感,也就是在值比对判断时大小写字母都一样; 2,等值,或<>判断,系统默认对等式两边比对值去右边空格再进行比较: 3,GROUP ...

  8. poj 1077 Eight (八数码问题——A*+cantor展开+奇偶剪枝)

    题目来源: http://poj.org/problem?id=1077 题目大意: 给你一个由1到8和x组成的3*3矩阵,x每次可以上下左右四个方向交换.求一条路径,得到12345678x这样的矩阵 ...

  9. 8086存储器组织和IO组织 奇偶分体

    8086的存储器组织 存储器的基本存储单位是字节,每个字节用唯一的地址码表示. 若存放的信息是8位的字节数据,将按顺序存放: 若存放的信息是16位的字数据,则将字的高位字节放在高地址中,低位字节放在低 ...

随机推荐

  1. Java面试—消息队列

    消息队列面试题 题目来自于中华石杉,解决方案根据自己的思路来总结而得. 题目主要如下: 1. 为什么要引入消息队列? 消息队列的引入可以解决3个核心问题: 解耦 异步 削峰 解耦 在一个项目中,如果一 ...

  2. 写入时复制(CopyOnWrite)

    一.CopyOnWrite 思想 写入时复制(CopyOnWrite,简称COW)思想是计算机程序设计领域中的一种通用优化策略.其核心思想是,如果有多个调用者(Callers)同时访问相同的资源(如内 ...

  3. 全文搜索引擎 Elasticsearch 入门:集群搭建

    本文主要介绍什么是 ElasticSearch 以及为什么需要它,如何在本机安装部署 ElasticSearch 实例,同时会演示安装 ElasticSearch 插件,以及如何在本地部署多实例集群, ...

  4. Android中使用Canvas和Paint绘制一个安卓机器人

    场景 在Android中画笔使用Paint类,画布使用Canvas类来表示. 绘图的基本步骤 首先编写一个继承自View的自定义View类,然后重写其onDraw方法,最后把自定义的view添加到ac ...

  5. GitHub当作私密的版本控制系统远端版本库私有化

    目的 我打算把所有服务器的配置文件用git管理起来,这样可以记录配置变更状况. 但是有一个问题是,如何多人协作?服务器配置信息非常敏感,如果这个版本库泄漏,整个公司的服务器架构就彻底泄漏了. 这个版本 ...

  6. go语言开发工具sublime text3 + gosublime配置

    开始go语言开发时,网上google了下go的开发工具,大都推荐 sublime text3+gosublime.但是实际操作中gosublime不能直接安装,需要自己手动安装.将自己的安装过程整理一 ...

  7. Django复制记录的方法

    最近的Django项目中有复制记录的需求.数据库里有一张名为Party的表,记录用户创建的party,现在要让用户能够复制一个新的party.本身非常简单的一个功能,但运行的时候出错了.我以为是复制过 ...

  8. linux--工具进阶

    linux学习 看完了基础篇,下面来看进阶篇 我好想哭看这的时候,好多只是听说过,但完全没有试过,感觉自己懂得有点少,就是缺乏一些知识储备,也就是必须知道了某些或学过了某些知识才适合来看这一部分,看得 ...

  9. KVM命令--优化篇(2)

    1- 为什么要调优 ___ KVM采用全虚拟化技术,全虚拟化要由一个软件来模拟硬件,故有一定的损耗,特别是I/O,因此需要优化. ___ KVM性能优化主要在CPU.内存.I/O这几方面.当然对于这几 ...

  10. function_use

    # 函数说明文档,help(len) def sum1(a, b): """ 求和函数sum1 :param a: 参数1 :param b: 参数2 :return: ...