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. 进阶之路 | 奇妙的Activity之旅

    前言 本文已经收录到我的Github个人博客,欢迎大佬们光临寒舍: 我的GIthub博客 本篇文章需要已经具备的知识: Activity的基本概念 AndroidManifest.xml的基本概念 学 ...

  2. Linux运维---02.制作trove-redis镜像

    redis-3.2 镜像制作及验证 镜像制作 1.安装redis yum install redis yum install epl-release yum install python-pip gi ...

  3. centos7安装Elasticsearch及Es-head插件详细教程(图文)

    懒惰了很久,今天来写一下Elasticsearch在centos7上安装教程以及安装过程中可能出现的报错解决方式,有不对的地方,烦请各位看官多多指教! 一.ES安装 1.环境检查 确保有java环境, ...

  4. 目前最全的Python的就业方向

    Python是一门面向对象的编程语言,编译速度超快,从诞生到现在已经25个年头了.它具有丰富和强大的库,常被称为“胶水语言”,能够把用其他语言编写的各种模块(尤其是C/C++)很轻松地联结在一起.其特 ...

  5. Dijkstra算法 1

    // Dijkstra算法,适用于没有负边的情况 // 注意:是没有负边,不是没有负环 // 在这一条件下,可以将算法进行优化 // 从O(v*E)的复杂度,到O(V^2)或者是O(E*log(V)) ...

  6. gRPC用法

    官方文档 前置技能 protobuf 什么是 gRPC? A high performance, open-source universal RPC framework RPC : Remote Pr ...

  7. 简单的说说tippyjs的使用

    我们会接触到很多插件的使用,但是我们该如何的去使用呢,本人建议多学习英语,会对开发很有帮助的 为什么说是多去学习它,接下来我们就来说说: 当你没学习英语看到下面的官网是这样子的 当你会英语了,你就会觉 ...

  8. php压缩文件zip格式并打包(单个或多个文件压缩)

    最近接到一个需求,就是选择多个文件下载时,不要一个一个下载,直接把多个文件打包成一个文件进行下载.我们项目是前后端分离,所以我写了个接口,让前端传参数,后台下载. 废话不多说,直接上代码: 先是压缩单 ...

  9. 教你如何理解JAVA的I/O类库

    花括号MC(huakuohao-mc):关注JAVA基础编程及大数据,注重经验分享及个人成长. Java 的 I/O 流,说简单也简单,说复杂也复杂.复杂是因为进行一次常规的文件 I/O 操作通常要用 ...

  10. AGC011-E Increasing Numbers

    题意 给定一个数\(n\),\(n≤10^{500,000}\),问\(n\)最少可以拆分成几个不降数的和.一个不降数是在十进制位下,从高位往低位看,每个数都不会比高位的数更小的数 做法 不降数可以拆 ...