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

时间:2023-03-09 01:28:47
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 <iostream>
using namespace std;
const int maxn = ;
int a, n, x = -, y = -;
int main()
{
cin >> n;
for (int i = ; i <= n; i ++)
{
cin >> a;
if (a % == )
x = (x == -) ? i : -;
else
y = (y == -) ? i : -;
}
cout << x + y + ;
return ;
}

C++