Arrange Numbers
Time Limit: 1 sec
Memory Limit: 756 MB
Attempts: 164
Accuracy: 1.83%
Author: Gulshan
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.
Input
The 1st line contains t = no. of questions
The next t lines contain a single integer n.
Output
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.
Constraints
t<=1e3
2<=n<=1e4
Time Limit = 1s
Example
Input:
2
2
3
Output
1
1
PASS
Explanation:
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.
ID
SUBMITTED AT
STATUS
LANGUAGE
TIME
MEMORY USED
USER
TIME
STATUS
LANGUAGE
TIME
MEMORY USED
11 months ago
cpp14
0.07 sec
64 KB
1 year ago
cpp14
0.07 sec
64 KB
2 years ago
cpp14
0.07 sec
64 KB
2 years ago
cpp
0.07 sec
64 KB
2 years ago
cpp14
0.07 sec
64 KB
2 years ago
cpp14
0.07 sec
64 KB
2 years ago
cpp14
0.07 sec
64 KB