QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#676944 | #5465. Maximum GCD | ANAS_IIUC | WA | 7ms | 10704kb | Python3 | 714b | 2024-10-26 04:15:31 | 2024-10-26 04:15:32 |
Judging History
answer
import math
import sys
input = sys.stdin.read
def max_beautiful_gcd(arr):
n = len(arr)
if n == 1:
return arr[0] # If there's only one element, its value is the max GCD
# Find the minimum element in the array
min_elem = min(arr)
# Calculate GCD of all (arr[i] - min_elem)
gcd_diff = 0
for num in arr:
gcd_diff = math.gcd(gcd_diff, num - min_elem)
if gcd_diff == 1:
break # No need to continue if gcd_diff is 1, as it is the smallest possible GCD
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))
详细
Test #1:
score: 0
Wrong Answer
time: 7ms
memory: 10704kb
input:
3 3 10 7
output:
1
result:
wrong answer 1st numbers differ - expected: '3', found: '1'