結果
問題 | No.125 悪の花弁 |
ユーザー | 👑 cologne |
提出日時 | 2022-02-28 22:08:20 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 480 ms / 5,000 ms |
コード長 | 693 bytes |
コンパイル時間 | 1,255 ms |
コンパイル使用メモリ | 86,712 KB |
実行使用メモリ | 92,876 KB |
最終ジャッジ日時 | 2023-09-21 07:01:26 |
合計ジャッジ時間 | 4,781 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 371 ms
80,028 KB |
testcase_01 | AC | 313 ms
92,760 KB |
testcase_02 | AC | 394 ms
92,808 KB |
testcase_03 | AC | 480 ms
92,876 KB |
testcase_04 | AC | 404 ms
81,060 KB |
testcase_05 | AC | 392 ms
77,752 KB |
ソースコード
from functools import reduce import math def main(): M = 10**9+7 def 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] += 1 ans = 0 for i in range(1, g+1): if cnt[i]: a = 1 for c in C: a = a*fact(c // i) % M ans = (ans + cnt[i] * fact(s//i) * pow(a, -1, M)) % M ans = ans * pow(s, -1, M) % M print(ans) return if __name__ == '__main__': main()