BNUOJ-4716题 IQ test

BNUOJ-4716 IQ test

网站  https://www.bnuoj.com/v3/problem_show.php?pid=4716

 

Bob is preparing to pass IQ test. The most frequent task in thistest is to find out which one of the given n numbers differs from the others. Bobobserved 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 inevenness.

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, notexceeding 100. It is guaranteed, that exactly one of these numbers differs fromthe 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 Input

Input

5
2 4 7 8 10

Output

3

Input

4
1 2 1 1

Output

2

 

#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
   int n,i,j,e,o,flag1,flag2,a;
   scanf("%d",&n);
   flag1=0;
   flag2=0;
   e=o=0;
   for(i=0;i<n;i++)
    {
       scanf("%d",&a);
       if(a%2==1)
       {
           e++;
           if(!flag1)
           {
                flag1=i+1;
           }
       }
       else
       {
           o++;
           if(!flag2) flag2=i+1;
       }
    }
if(e==1) //  按题意只有2种情况,1)输入的数字中只有一个奇数的情况,
//2)输入的数字中只有一个偶数
printf("%d\n",flag1);
   else printf("%d\n",flag2);
}

 

 

 

 

 

/*   题目说    找出输入的数中   比较特别的一个  并输出它的序号

英语战5渣渣的我看题后,以为是等差数列 。。。。

wa了几次,求助队友,才理解题意,下次争取一次就通过,不要再错了*/

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值