IITKWPCF - Help Feluda with mathematical equations
Feluda likes numbers very much but hates prime numbers too much. For a fixed n, you gave Feluda eqution x^2 + y^2 + n = (x + y) ^ 2. Now you only want positive integral solution of x and y. Feluda being an intelligent person gave you all the pairs of (x, y) but he missed the pairs which had x as a prime number.
For all the solution that Feluda gave you, we want you to just print those values in the following format: first print the number of such x's, then the possible values x sorted in increasing order in a line seperated by single space. If no such numbers exist, then print a 0 in the line.
T : number of test cases (T <= 100)
For next T lines each line contain n (n <= 10^12)
For every test case print as stated in the problem statement.
4 1 4 6 12
4 1 10 25 50
For those disappointed, do it in Python - bruteforce won't work there, I tried ;) Nice problem in that its complexity rewards time spent optimizing functions for other NT problems that you can reuse here. Half year ago I would probably have TLEd with the same approach.
what shout be the output of 1 1
for input=> 0
such a waste question >:(
free mind ;):
@praveen123 : please check my solution (Runtime Error ) :(
brute force will work with optimization
YOU Sir/Madam, deserve a medal for putting this problem on here. Awesome, as a mathematician I must say this is one of the problems that I adore most.
@praveen123 : please check my solution(WA)
@shivam agarwal: 154