Change parity
Practice
4.5 (2 votes)
Binary search algorithm
Mathamatics
Basic math
Easy
Mathematics
Mathematics
Problem
83% Success 445 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code
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
\(1 \le T \le 10^{5} \)
\(1 \le X \le 10^8 \)
Sample Input
1 3
Sample Output
4
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.
Code Editor
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Submissions
Please login to view your submissions
Similar Problems
Points:20
16 votes
Tags:
AlgorithmsEasyString Manipulation
Points:20
Tags:
Easy
Points:50
2 votes
Tags:
MathematicsHardOpenApproved
Editorial
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor