Skip to content

Instantly share code, notes, and snippets.

@IKKO-Ohta
Created July 1, 2017 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IKKO-Ohta/a994597c32b9f49d22fea8cc8da4f1b2 to your computer and use it in GitHub Desktop.
Save IKKO-Ohta/a994597c32b9f49d22fea8cc8da4f1b2 to your computer and use it in GitHub Desktop.
def myfind(coin_self,all_coins):
"""
目標コインとコイン全体を引数に取る。
その目標コインが約数に取り得るコインが何枚あるか(S)を返す。
"""
factor = -1
for c in coins:
if coin_self % c == 0: factor += 1
return factor
if __name__ == '__main__':
N = int(input())
coins = []
for i in range(N): coins.append(int(input()))
accum = 0
for coin in coins:
S = myfind(coin,coins)
if S % 2 == 0: accum += (S+2) / (2*S+2)
else: accum += 0.5
print(accum)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment