Code
from math import gcd
def max_gcd_sum(arr):
n = len(arr)
arr.sort(reverse=True)
odd_gcd, even_gcd = arr[0], arr[1]
for i in range(2, n):
if i % 2 == 0:
even_gcd = gcd(even_gcd, arr[i])
else:
odd_gcd = gcd(odd_gcd, arr[i])
return odd_gcd + even_gcd
Information
- Submit By
- Type
- Pretest
- Problem
- P1076 Even Odd GCD (Easy Version)
- Language
- Python 3 (Python 3.12.3)
- Submit At
- 2024-08-16 16:27:42
- Judged At
- 2024-10-03 13:26:52
- Judged By
- Score
- 0
- Total Time
- 21ms
- Peak Memory
- 3.062 MiB