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. C++泛化动态数组

    泛化动态数组 动态数组的核心思想是在存储数据时动态的管理数组元素占用的内存,通过调用动态数组的类方法来对数组中的数据进行增删改查操作.最初我们为数组申请10个元素的空间,放我们不断向数组中添加数据时, ...

  2. Redis入门(介绍、搭建)——Windows、Centos环境

    一.介绍 Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cac ...

  3. 使用JDBC获取数据库中的一条记录并封装为Bean

    比如我数据库中存入的是一条一条的用户信息,现在想取出一个人的个人信息,并封装为Bean对象,可以使用queryForObject来获取数据并通过new BeanPropertyRowMapper(Be ...

  4. IIS6的文件解析漏洞

    IIS6的默认配置漏洞会把cer.cdx.asa作为asp代码来解析 后缀解析漏洞 /test.asp;.jpg 或者/test.asp:.jpg(此处需抓包修改文件名) IIS6.0 都会把此类后缀 ...

  5. EasyUI笔记(三)Window窗口

    本系列只列出一些常用的属性.事件或方法,具体完整知识请查看API文档 Window(窗口) 窗口控件是一个浮动和可拖拽的面板可以用作应用程序窗口.默认情况下,窗口可以移动,调整大小和关闭.它的内容也可 ...

  6. 数据库中间件DBLE学习(二) 学习配置schema.xml

    前言 一边有一个经常引诱我让我"娱乐至死"的视频,还有一个不停"鞭策"我让我快点学习的大BOSS.正是有这两种极端的爱才让我常常在自信中明白自己努力的方向.嗯, ...

  7. 数据结构(集合)学习之List

    集合 框架关系图: Collection接口下面有三个子接口:List.Set.Queue.此篇是关于List<E>的简单学习总结. 补充:HashTable父类是Dictionary,不 ...

  8. B. Modulo Equality

    当时想到的第一个想法是用拓展欧几里得解方程,求x的最小正解.一发交了之后发现爆long long,因为m是1e9. 因此本题的正解是暴力,保证有解的情况下,那么a数组中的一个数必然对应着b数组中的一个 ...

  9. 给你的HTTPS添加Let's Encrypt证书

    Let’s Encrypt setup for Apache, NGINX & Node.js https://gist.github.com/davestevens/c9e437afbb41 ...

  10. 11maven的聚合

    我们都知道项目之间的依赖首先要把被依赖的项目先安装install到maven的本地仓库中,然后在本项目中配置被依赖的仓库坐标,才能进行依赖通信. 例如: A项目 >  B项目 A项目依赖B项目中 ...