-
Notifications
You must be signed in to change notification settings - Fork 0
/
Even_Odd_Query.cpp
74 lines (61 loc) · 1.37 KB
/
Even_Odd_Query.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <deque>
#include <iostream>
#include <list>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define ll long long
#define MIN(a, b) a < b ? a : b
#define MAX(a, b) a > b ? a : b
using namespace std;
int readline(char *str) {
int i = 0;
char ch;
while((ch = getchar()) != '\n') {
str[i++] = ch;
}
str[i] = '\0';
return i;
}
int arr[100010];
int npow(int a, int b) {
if(b == 0) {
//printf(" pow = %d - B\n", 1);
return 1;
}
//printf(" pow = %d - C\n", (a & 1) ? 1 : 2);
return (a & 1) ? 1 : 2;
}
int main(int argc, char *argv[]) {
int n, q;
int x, y;
char result[4][8] = {"Even", "Odd"};
scanf("%d", &n);
for(int i = 1; i <= n ; i++ ) {
scanf("%d", &arr[i]);
}
scanf("%d", &q);
while(q--) {
int ans;
scanf("%d%d", &x, &y);
if(x < n && arr[x + 1] == 0 && x != y ) {
// Since the value just after "x"th index is 0
// so no matter what ans will be 1 -> odd
ans = 1;
}
else {
// In all other cases the odd/even of base determines
// the odd/even of result
ans = arr[x];
}
printf("%s\n", result[ans & 1]);
}
return 0;
}