wrong answer , tle error
n = int(input())
for x in range(n):
c = int(input())
for i in range(c + 1):
for j in range(i + 1):
if(pow(j,2) + pow(i,2) == c):
print("({},{})".format(j,i),end = " ")
print()
please check my code
Why solution is not accepted in python
n = int(input()) for x in range(n): c = int(input()) for i in range(c + 1): for j in range(i + 1): if(pow(j,2) + pow(i,2) == c): print("({},{})".format(j,i),end = " ") print()
Take an example 25 - your code returns (3,4) (0,5) while we want answer to be sorted according to the first number i.e (0,5) (3,4). Just try changing for loops range
And you can optimize your code by traversing only till sqrt(number)
I hope I’ve cleared your doubt.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
import math
t=int(input())
for i in range(0,t):
a =int(input())
b= int(math.sqrt(a))
for j in range(0,b):
c=int(a-(jj))
d=int(math.sqrt©)
if jj+d*d == a and j <= d:
tuple1=(j,d)
res=str(tuple1).replace(’ ‘,’’)
print(res,end=" ")
print(end="\n")
getting wrong answer for second test case. Can anyone help?
like gnewsclient is for getting news, what if I want to access articles about mental issues likes depression , their symptoms and their treatment and about other things related to them