BNUOJ-4716题 IQ test
来源:互联网 发布:第七感大底软件 编辑:程序博客网 时间:2024/05/16 14:56
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
52 4 7 8 10
Output
3
Input
41 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);}
/* 题目说 找出输入的数中 比较特别的一个 并输出它的序号
第一遍看题 我还以为是等差数列 ,我没和队友说,打算做时队友说他来负责这题,好吧我看别的题,队友一次就a了,还好这个题不是我负责,否则这题至少要浪费我半小时,以后遇到水题,想法要说给队友听,争取一次就a了*/
- BNUOJ-4716题 IQ test
- IQ Test
- A. IQ test
- A. IQ Test
- LA 6449 IQ Test
- TOJ 4118 IQ test
- 周赛 IQ test
- A. IQ test
- codeforces 328A. IQ Test
- codeforces A. IQ test 题解
- CF —— IQ Test
- UVALive 6449 IQ Test --高斯消元?
- Codeforces 25A IQ test
- 【CodeForces】[25A]IQ test
- IQ题
- IQ Test for Top500 Enterprise Cooperation
- CodeForces Testing Round #8 A.IQ Test
- Codeforces-287a C IQ Test
- CodeForces 628C
- iPhone4s刷机教程
- Android - View的绘制流程一(measure)
- ZOJ 1610 Count the Colors 多次更新一次查询,只需要一一标记
- hdu 5667 矩阵快速幂
- BNUOJ-4716题 IQ test
- Oracle以及SqlServer 2008 查询表是否存在
- BestCoder Round #81 (div.2)-Matrix(模拟)
- Windows下使用Beyond Compare作为git的比对与合并工具
- 牛腩新闻发布系统——用例图知识,温故知新
- Android Studio2.0在Android5.0以下机型无法调试
- HDU 5671 矩阵的交换行、交换列,整行加一个数 思维题
- Android - View的绘制流程二(layout)
- 【Raspberry Pi 3试用体验】+ 中文显示及输入+百度云传输