Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Svastikkka/32e802541a0218c2a23b54ff9a4d9689 to your computer and use it in GitHub Desktop.
Save Svastikkka/32e802541a0218c2a23b54ff9a4d9689 to your computer and use it in GitHub Desktop.
t=int(input())
for i in range(t):
n,k=map(int,input().split())
arr=list(map(int,input().split()))
res=sorted(arr)
largest_divisor=0
for i in res:
# 3
if k % i == 0:
# 4
largest_divisor = i
if largest_divisor in arr:
print(largest_divisor)
else:
print(-1)
@Svastikkka
Copy link
Author

Chef and Linear Chess Problem Code: LINCHESS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment