def ok(A): for a, b, c in zip(A, A[1:], A[2:]): if b ** 2 != a * c: return False return…
- User
def ok(A): for a, b, c in zip(A, A[1:], A[2:]): if b ** 2 != a * c: return False return True
t = int(input()) for _ in range(t): n = int(input()) A = list(map(int, input().split()))
B = [a for a in A if a > 0] C = [a for a in A if a < 0] D = [abs(a) for a in A] S = set(A) if len(S) <= 1: print("Yes") continue if len(S) == 2: temp = list(S) a, b = temp[0], temp[1] if abs(A.count(a) - A.count(b)) > 1: print("No") else: print("Yes") continue if len(A) != len(S): print("No") continue B.sort() C.sort() D.sort() if ok(B) and ok(C) and ok(D): print("Yes") else: print("No")このコードの間違いを修正してください.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.