← Back to List

21920번: 서로소 평균 ↗

Solutions

Python 3
160 B | 160 chars
def gcd(a,b):
 return gcd(b,a%b) if b>0 else a
input()
l=[*map(int, input().split())]
x=int(input())
ans=[i for i in l if gcd(x,i)==1]
print(sum(ans)/len(ans))