time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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.

Sample test(s)
input
5
2 4 7 8 10
output
3
input
4
1 2 1 1
output
2

解题报告:水题。。

。给你一列数,当中仅仅有一个数的奇偶性和其它数不同,输出它所在的位置。直接暴力扫一遍,记录最后一个奇数和偶数的位置,并记录奇数和偶数的个数。就可以。

AC代码:

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
#define INF 0x7fffffff int a[105]; int main()
{
#ifdef sxk
freopen("in.txt","r",stdin);
#endif
int n;
while(scanf("%d",&n)!=EOF)
{
int ans1 = 0, ans2 = 0, x, y;
for(int i=0; i<n; i++){
cin>>a[i];
if(a[i]&1) {
ans1 ++;
x = i+1;
}
else{
ans2 ++;
y = i+1;
}
}
if(ans1>ans2) cout<<y<<endl; //推断条件也可换成ans1 == 1
else cout<<x<<endl;
}
return 0;
}

Codeforces Beta Round #25 (Div. 2)--A. IQ test的更多相关文章

  1. Codeforces Beta Round #25 (Div. 2 Only)

    Codeforces Beta Round #25 (Div. 2 Only) http://codeforces.com/contest/25 A #include<bits/stdc++.h ...

  2. codeforces水题100道 第十七题 Codeforces Beta Round #25 (Div. 2 Only) A. IQ test (brute force)

    题目链接:http://www.codeforces.com/problemset/problem/25/A题意:在n个书中找到唯一一个奇偶性和其他n-1个数不同的数.C++代码: #include ...

  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. Codeforces Beta Round #25 (Div. 2 Only)E. Test

    E. Test time limit per test 2 seconds memory limit per test 256 megabytes input standard input outpu ...

  5. Codeforces Beta Round #25 (Div. 2 Only)D. Roads not only in Berland

    D. Roads not only in Berland time limit per test 2 seconds memory limit per test 256 megabytes input ...

  6. Codeforces Beta Round #25 (Div. 2 Only) C. Roads in Berland

    C. Roads in Berland time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  7. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  8. Codeforces Beta Round #49 (Div. 2)

    Codeforces Beta Round #49 (Div. 2) http://codeforces.com/contest/53 A #include<bits/stdc++.h> ...

  9. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

随机推荐

  1. 在redhat下使用x11vnc进行桌面共享

    1.在redhat上安装x11vnc时.你须要注意下面几个方面: (1)下载x11vnc的源代码包: 网址例如以下所看到的: http://sourceforge.net/projects/libvn ...

  2. 你是那种仅仅看《XXXXX从入门到精通》的程序猿吗?

    我一開始又要废话一番了. 实际上上了大学以后.你常常会在网上,在和别人的交流里,在老师的课堂上.反复听到一些书,比方黄仁宇的<万历十五年>.王小波"时代三部曲".村上春 ...

  3. nmap小技巧[1] 探测大网络空间中的存活主机

    url: nmap是所有安全爱好者应该熟练掌握的扫描工具,本篇介绍其在扫描大网络空间时的用法. 为什么要扫描大网络空间呢? 有这样的情形: 内网渗透   攻击者单点突破,进入内网后,需进一步扩大成果, ...

  4. Python——描述符(descriptor)解密

    本文由 极客范 - 慕容老匹夫 翻译自 Chris Beaumont.欢迎加入极客翻译小组,同我们一道翻译与分享.转载请参见文章末尾处的要求. Python中包含了许多内建的语言特性,它们使得代码简洁 ...

  5. JS动态插入HTML后不能执行后续JQUERY操作

    通过js追加的html 发现 不能点击 执行函数   普通绑定事件:$('.btn1').click(function(){}绑定 事件委托   解决方法: $("body").d ...

  6. JavaScriptl 类数组转换为数组

    slice和Array.form方法,具体见示例代码: <!DOCTYPE html> <html lang="zh"> <head> < ...

  7. GBDT--简单理解

    梳理 1.Model Ensemble 能够分为三大类:Bagging,Boosting. Stacking. 2.Boosting能够说是一个思想(框架),而Adaboost等算法仅仅是其一个子类, ...

  8. Visual studio C++ 之空控制台工程添加文件并解决头文件包含问题

    背景 之前都是用的MFC已搭好框架,今天想自己从零开始完成添加文件,编译,并解决文件包含问题,在此做个记录. 正文 首先创建一个Win32控制台应用程序,不要直接点击完成,而是点击下一步,然后选择空项 ...

  9. iOS开发-在Swift里使用AFNetworking方法

    在OC里使用惯了AFNetworking,比较喜欢这一个第三方库,在别的途径里得知可以在Swift里使用AFNetworking.但是那个时候我不知道具体的操作是怎样的,于是我只能去百度.GOOGLE ...

  10. 在Eclipse中导入dtd和xsd文件,使XML自动提示(转)

    DTD 类型约束文件 1. Window->Preferences->XML->XML Catalog->User Specified Entries窗口中,选择Add 按纽 ...