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
hide comments
Ozo:
2012-05-21 14:46:17
Tutorial!! |
|
Giorgos Christoglou:
2012-05-17 08:36:02
care after output print newline !
|
|
Paras Sharma:
2012-05-02 10:54:49
too easy.. you won't even need paper & pen to solve this one :p |
|
Shizuo Heiwajima:
2012-05-02 05:39:36
What kind of problem it is?? To easyy |
|
jobless:
2012-04-27 09:03:33
@Rodolfo See the constraints for N |
|
Rocker3011:
2012-04-26 23:21:38
what would be output for 0,1,2 and 3? |
|
Rishi Mukherje:
2012-04-26 07:34:42
Rodolfo: yes kindof! :P |
|
Devil D:
2012-04-24 07:31:33
na not add even |
|
Rocker3011:
2012-04-22 04:31:22
isnt this an odd and even comparision? Last edit: 2012-04-22 04:31:31 |
|
spock:
2012-04-21 22:10:48
got it wrong at first...costed me a lots of WA's.. :( |
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 |