QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#676943#5465. Maximum GCDANAS_IIUCWA 12ms10768kbPython3568b2024-10-26 04:13:322024-10-26 04:13:32

Judging History

你现在查看的是最新测评结果

  • [2024-10-26 04:13:32]
  • 评测
  • 测评结果:WA
  • 用时:12ms
  • 内存:10768kb
  • [2024-10-26 04:13:32]
  • 提交

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'