-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA_IQ_test.cpp
57 lines (56 loc) · 1.08 KB
/
A_IQ_test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
int a[n], even = 0;
for (int i = 1; i <= n; i++)
{
cin >> a[i];
if (a[i] % 2 == 0)
even++;
}
//cout<<even<<endl;
if (even == 1)
{
for (int i = 1; i <= n; i++)
{
if (a[i] % 2 == 0)
cout << i << endl;
}
}
else
{
{
for (int i = 1; i <= n; i++)
{
if (a[i] % 2 == 1)
cout << i << endl;
}
}
}
}*/
//optimize code
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
vector<int>v(n);
int odd=0,even=0,even_index=0,odd_index=0;
for(int i=0;i<n;i++){
cin>>v[i];
if(v[i]%2==0){
even++;
even_index = i+1;
}
else{
odd++;
odd_index=i+1;
}
}
if(even==1)cout<<even_index<<endl;
else cout<<odd_index<<endl;
return 0;
}