Submit | All submissions | Best solutions | Back to list |
TECHELN5 - Do You know your Algorithms |
Jonny has just learned sorting in his algorithm classes. He wants to show his mother how good he is with algorithms, but his mother is very clever. She wants to ensure Jonny has learned the key concepts and not just the methods.
She places N integers in order 1, 2, 3 ... N. and asks Jonny to reverse this sequence, i.e. convert this sequence to N, N-1 ... 3, 2, 1. The only operation Jonny is allowed to do is to choose any 4 (not necessarily adjacent) integers and perform the following action: exchange the left-most integer with the right-most one and similarly swap the remaining two integers in the middle, both swaps must occur. He can perform this operation as many times he want.
Jonny has a feeling that this may not always be possible for all sequences, so before starting he wants to know whether it is possible to do this task.
Input
First line of the input contains T, the number of test cases. Then follow T lines, each containing an integer N.
Output
For each of the given numbers print YES if the task is possible, otherwise NO.
Example
Input: 2 5 6 Output: YES NO
Constraints
1 <= T <= 10
4 <= N <= 1,000,000
Added by: | Nikunj Jain |
Date: | 2012-04-17 |
Time limit: | 0.5s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | https://sequoia.interviewstreet.com/challenges/dashboard/#problem/4f889e56432a3 |
hide comments
|
|||||
2012-04-21 05:51:57 avinash
tutorial problem :) |
|||||
2012-04-19 06:05:32 Devil D
Just write down some examples on paper and you will get the result. |
|||||
2012-04-17 17:46:15 Alex Anderson
Not particularly interesting. Last edit: 2012-04-17 17:46:27 |