結果
問題 | No.125 悪の花弁 |
ユーザー |
|
提出日時 | 2022-02-28 22:08:20 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 342 ms / 5,000 ms |
コード長 | 693 bytes |
コンパイル時間 | 214 ms |
コンパイル使用メモリ | 82,604 KB |
実行使用メモリ | 92,140 KB |
最終ジャッジ日時 | 2024-07-07 01:27:44 |
合計ジャッジ時間 | 2,676 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 6 |
ソースコード
from functools import reduceimport mathdef main():M = 10**9+7def fact(x): return reduce(lambda a, b: a*b % M, range(1, x+1), 1)int(input()) # K*C, = map(int, input().split())g = reduce(math.gcd, C, 0)s = sum(C)cnt = [0 for i in range(g+1)]for i in range(s):x = s // math.gcd(s, i)if g % x == 0:cnt[x] += 1ans = 0for i in range(1, g+1):if cnt[i]:a = 1for c in C:a = a*fact(c // i) % Mans = (ans + cnt[i] * fact(s//i) * pow(a, -1, M)) % Mans = ans * pow(s, -1, M) % Mprint(ans)returnif __name__ == '__main__':main()