結果

問題 No.125 悪の花弁
ユーザー shotoyooshotoyoo
提出日時 2021-06-24 00:06:00
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,016 bytes
コンパイル時間 302 ms
コンパイル使用メモリ 87,180 KB
実行使用メモリ 166,352 KB
最終ジャッジ日時 2023-09-07 05:51:44
合計ジャッジ時間 2,101 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 142 ms
142,960 KB
testcase_02 AC 162 ms
165,824 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))

### 約数列挙
def fs(n):
    s = set()
    for i in range(1,int(n**0.5)+2):
        if n%i==0:
            s.add(i)
            s.add(n//i)
    l = sorted(list(s))
    return l

k = int(input())
c = list(map(int, input().split()))
M = 10**9+7
ans = 0
size = 0
n = sum(c)
from math import gcd
g = c[0]
for i in range(1,k):
    g = gcd(g, c[i])
g1 = [1]
for i in range(1, n+1):
    g1.append(g1[-1]*i%M)
f = fs(g)
_inv = {}
def inv(v):
    if v in _inv:
        return _inv[v]
    val = pow(v, M-2, M)
    _inv[v] = val
    return val
for v in f:
    d = n//v
    val = g1[d]
#     assert d==sum((cc//v for cc in c))
    for cc in c:
        val *= inv(g1[cc//v])
        val %= M
    ans += val * (1 if d*2%n==0 else 2)
    ans %= M
#     print(d,v,val)
ans *= pow(n, M-2, M)
print(ans%M)
0