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