IITKWPCB - Check the coprimeness
Find largest non-negative number less than or equal to floor (N/2) which is coprime to N.
Two number a and b are considered to coprime if gcd (a, b) = 1.
T : numbr of test cases (T <= 1000)
For next T lines, every line contains n >= 1 && n <= 10^12;
For each test case, output as described in the problem statement.
Don't worry about n==1 case.
ac in one go
Just make sure that if you are using C you might keep getting a wrong answer even though your logic might be correct because of the incorrect data type. Use unsigned long long int and also while using printf, try using inttype.h library! otherwise,core logic is simple.
Easy Question. At first I just ran a loop to find the GCD=1 condition it passed (had guessed that we'll always have an answer) but then the comments provided with another approach the pattern approach which was too easy to code :)
brute force it and get the pattern and then its O(1)
You don't need any of GCD, floor, or anything.
no need of gcd,floor,just should hv an idea of coprime no. i.e. they have only d factor 1 in common
develop the pattern and thats it
waste my time where O(1) solution exists. Problem statement should be changed to "See the test cases and develop solution"
simple just think for even and odd numbers