Person A appears for an entrance test to 'ABC academy'. He is given the following question:-
Arrange the natural numbers from 1 to n such that the absolute value of differences between the consecutive numbers >= k. Write the maximum value of k possible.
He doesn't know how to solve this problem completely but his intuition tells him that k <= n. So, he uses his lucky number(1024) and gives the answer as k=(1024 % n)+1 for all the cases. He will pass if he can answer at least (1/2) of the t questions correctly.(NOTE: for t=odd A passes for (t-1)/2 correct answers.)
# TASKS TO PERFORM are explained below in Output section.
The 1st line contains t = no. of questions
The next t lines contain a single integer n.
For each n print the correct value of k in a new line.
IN THE (t+1)th line PRINT "PASS" if he passes or "FAIL" if he fails.
Time Limit = 1s
The answers given by A are:- (1024%2)+1 = 1 (1024%3)+1 = 2
For n=2: numbers can only be arranged as [1 2] or [2 1]. Thus, k=1.
For n=3: [2 1 3] (2-1 = 1), (3-1=2) so k=1. Other arrangements give k=1 too.
So, he answered correctly 1 question out of 2. (1/2) of 2 gives 1. So, he passes.