結果

問題 No.797 Noelちゃんとピラミッド
ユーザー roaris
提出日時 2019-08-12 10:36:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 260 ms / 2,000 ms
コード長 340 bytes
コンパイル時間 524 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 99,200 KB
最終ジャッジ日時 2024-09-15 07:35:00
合計ジャッジ時間 11,820 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 60
権限があれば一括ダウンロードができます

ソースコード

diff #

def inv(x):
    return pow(x, MOD-2, MOD)

def C(n, r):
    return fact[n] * inv(fact[r]) * inv(fact[n-r])

N = int(input())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7

fact = [1]

for i in range(1, N+1):
    fact.append(fact[-1] * i % MOD)
    
ans = 0

for i in range(N):
    ans += C(N-1, i) * a[i]
    ans %= MOD

print(ans)
0