codeforces——25A——IQ test

来源:互联网 发布:考研英语二参考书知乎 编辑:程序博客网 时间:2024/05/21 11:14
A. IQ test
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 givenn 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 givenn 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 containsn 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
52 4 7 8 10
Output
3
Input
41 2 1 1
Output
2



题意是有一个数奇偶性与其他数不同,输出这是第几个数

水题~

#include<stdio.h>#include<iostream>#include<cstring>#include<cmath>#include<algorithm>using namespace std;int main(){    int n;    while(~scanf("%d",&n))    {        int ji=0,ou=0,positionji,positionou;        for(int i=0; i<n; i++)        {            int t;            cin>>t;            if(t%2==0)            {                ou++;                if(ou==1)                    positionou=i+1;            }            else            {                ji++;                if(ji==1)                    positionji=i+1;            }            if((ou>1&&ji==1)||(ou==1&&ji>1))            {                if(ji==1)                    cout<<positionji<<endl;                else                    cout<<positionou<<endl;                ou=ji=10;            }        }    }    return 0;}


原创粉丝点击