Change parity

4.5

2 votes
, binary search algorithm, mathamatics, basic math, easy, Mathematics, mathematics
Problem

Let P(X) be the parity of a number which is defined as N, where N is the number of integers that divide X.
You are given a number X and you have to determine the smallest number Y such that Y > X and P(Y)!=P(X).

Input format

  • First line: T (number of test cases)
  • For each test case: X

Output format
For each test case, print the required answer on a separate line.

Constraints
1T105
1X108

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Numbers dividing 3 are 1 and 3 (N=2).
Numbers dividing 4 are 1, 2 and 4 (N=3). Hence the output is 4.

Editor Image

?