結果
問題 | No.1081 和の和 |
ユーザー |
![]() |
提出日時 | 2020-06-19 21:24:00 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 30 ms / 2,000 ms |
コード長 | 794 bytes |
コンパイル時間 | 72 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-07-03 13:39:16 |
合計ジャッジ時間 | 883 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 |
ソースコード
class PascalsTriangle:def __init__(self, N):self.N = Nself._build()def __call__(self, n, r):if n > self.N:raise "INVALID INPUT: input n must be smaller than N"if r < 0 or r > N:return 0return self.nCr[n][r]def _build(self):tmp = [(1,)]for i in range(1, self.N + 1):nCi = tuple(1 if j in (0, i)else tmp[-1][j-1] + tmp[-1][j] for j in range(i+1))tmp.append(nCi)self.nCr = tuple(tmp)if __name__ == "__main__":N = int(input())A = list(map(int, input().split()))pt = PascalsTriangle(N)mod = 10 ** 9 + 7ans = 0for a, x in zip(A, pt.nCr[N - 1]):ans += a * xans %= modprint(ans)