codeforces——25A——IQ test
来源:互联网 发布:考研英语二参考书知乎 编辑:程序博客网 时间:2024/05/21 11:14
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.
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 index of number that differs from the others in evenness. Numbers are numbered from 1 in the input order
52 4 7 8 10
3
41 2 1 1
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;}
- codeforces——25A——IQ test
- Codeforces 25A IQ test
- 【CodeForces】[25A]IQ test
- CodeForces 25A IQ test 唯一奇偶
- CF —— IQ Test
- codeforces 328A. IQ Test
- codeforces A. IQ test 题解
- codeforces-25A-A. IQ test( C && 怡宝 )
- Codeforces Beta Round #25 (Div. 2)--A. IQ test
- CodeForces 25A IQ test 唯一奇偶(简单的题目)
- CodeForces Testing Round #8 A.IQ Test
- Codeforces-287a C IQ Test
- Codeforces 328A-IQ Test(数列)
- 【水模拟】#25 A. IQ test
- Codeforces Testing Round #8 / 328A IQ Test(模拟)
- A. IQ test
- A. IQ Test
- A. IQ test
- AOP学习笔记(二)——Spring AOP
- Unity API(一)Unity中的脚本事件及其函数
- 应届生面试相关问题
- FreeMarker简单使用及介绍
- spring.xml配置文件连接数据库
- codeforces——25A——IQ test
- 【2014年第五届蓝桥杯C/C++程序设计本科B组决赛 出栈次序(结果填空) 】
- 17.05.20 总结
- 总结9
- 图论(十)最小生成树-Prim算法
- 一个项目里面包含多个子项目jar包的配置实现
- Spring思维导图,让Spring不再难懂(ioc篇)
- Android Java层与Jni层的数组传递
- android studio 3.0 preview 解决Gradle: Configure Project or Gradle: Resolve Dependencies ':classpath