Submit | All submissions | Best solutions | Back to list |
MOZSAS - Shahadat and Sequence |
Shahadat is a great programmer who loves sequences. All the time he thinks about sequences. He is so fond of sequences that sometimes he finds new sequences in his dreams.
One day he fell asleep and in his dream he found a new sequence, which is as follows:
(2x1), (2x2 + 1), (2x3), (2x4 + 1) ... (2xn + 1)
Where, 1 <= xi <= 30, n is even number and 2 <= n <= 105.
For simplicity, you can think it as an array (A) of n integers. Where:
- A[1] = 2x1
- A[2] = 2x2 + 1
- A[3] = 2x3
- ...
- A[n] = 2xn + 1
You will be given the values of x1, x2 ... xn.
You have to answer Q (1 <= Q <= 105) queries. In each query you will be given two integers l and r (1 <= l <= r <= n). You have to answer whether the summation of all elements of array A from l to r (inclusive) is even or odd.
Input
In the first line you will be given an integer n. In the next line you will be given n integers which are the values of x1, x2 ... xn. In the third line you will be given an integer Q. In the next Q lines you will be given two integers l and r.
Output
For each query print "Even" if (A[l] + a[l+1] + ... + A[r]) is even, otherwise print "Odd" without quotes.
Constraints
1 <= xi <= 30
2 <= n <= 105 and n is even.
1 <= Q <= 105
1 <= l <= r <= n
For better understanding see the sample input output.
Example
Input: 5 3 2 1 2 2 3 1 3 2 5 2 3 Output: Odd Even Odd
Added by: | Mozahid |
Date: | 2019-02-13 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
Resource: | Own |
hide comments
2024-02-22 23:51:02 Simes
@heraclitus22, No idea, my solution ignores both N and all Xi. |
|
2024-02-15 16:09:05
@Simes, there is a subtlety to it: what if xi==0 ? |
|
2023-02-13 16:14:39 Simes
The description and input both contain a lot of unnecessary information. Filter it out and you're left with a a simple problem. |