QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#676943 | #5465. Maximum GCD | ANAS_IIUC | WA | 12ms | 10768kb | Python3 | 568b | 2024-10-26 04:13:32 | 2024-10-26 04:13:32 |
Judging History
answer
import math
import sys
input = sys.stdin.read
def max_beautiful_gcd(arr):
if len(arr) == 1:
return arr[0] # If there's only one element, its value is the max GCD
arr.sort() # Sort the array
gcd_diff = arr[1] - arr[0] # Start with the first difference
for i in range(2, len(arr)):
gcd_diff = math.gcd(gcd_diff, arr[i] - arr[i - 1])
return gcd_diff
# Input reading
data = input().split()
n = int(data[0])
arr = list(map(int, data[1:]))
# Output the result
print(max_beautiful_gcd(arr))
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 12ms
memory: 10768kb
input:
3 3 10 7
output:
1
result:
wrong answer 1st numbers differ - expected: '3', found: '1'