結果

問題 No.797 Noelちゃんとピラミッド
ユーザー ronpooronpoo
提出日時 2023-08-29 16:45:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 585 bytes
コンパイル時間 622 ms
コンパイル使用メモリ 87,236 KB
実行使用メモリ 101,852 KB
最終ジャッジ日時 2023-08-29 16:46:11
合計ジャッジ時間 10,970 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
77,972 KB
testcase_01 AC 83 ms
78,068 KB
testcase_02 AC 82 ms
77,976 KB
testcase_03 AC 119 ms
101,396 KB
testcase_04 AC 116 ms
101,788 KB
testcase_05 AC 116 ms
101,704 KB
testcase_06 AC 117 ms
101,468 KB
testcase_07 AC 117 ms
101,532 KB
testcase_08 AC 117 ms
101,652 KB
testcase_09 AC 117 ms
101,600 KB
testcase_10 AC 116 ms
101,732 KB
testcase_11 AC 115 ms
101,680 KB
testcase_12 AC 114 ms
101,504 KB
testcase_13 AC 117 ms
101,852 KB
testcase_14 AC 118 ms
101,532 KB
testcase_15 AC 116 ms
101,676 KB
testcase_16 AC 116 ms
101,572 KB
testcase_17 AC 116 ms
101,380 KB
testcase_18 AC 115 ms
101,668 KB
testcase_19 AC 115 ms
101,464 KB
testcase_20 AC 116 ms
101,516 KB
testcase_21 AC 115 ms
101,700 KB
testcase_22 AC 116 ms
101,508 KB
testcase_23 AC 105 ms
93,952 KB
testcase_24 AC 92 ms
81,036 KB
testcase_25 AC 103 ms
91,584 KB
testcase_26 AC 101 ms
90,184 KB
testcase_27 AC 127 ms
101,232 KB
testcase_28 AC 110 ms
98,820 KB
testcase_29 AC 89 ms
78,832 KB
testcase_30 AC 93 ms
80,972 KB
testcase_31 AC 106 ms
93,708 KB
testcase_32 AC 97 ms
83,308 KB
testcase_33 AC 104 ms
91,692 KB
testcase_34 AC 98 ms
86,888 KB
testcase_35 AC 116 ms
101,532 KB
testcase_36 AC 89 ms
78,752 KB
testcase_37 AC 145 ms
98,276 KB
testcase_38 AC 115 ms
100,796 KB
testcase_39 AC 101 ms
91,360 KB
testcase_40 AC 86 ms
79,160 KB
testcase_41 AC 90 ms
79,728 KB
testcase_42 AC 101 ms
89,836 KB
testcase_43 AC 82 ms
78,216 KB
testcase_44 AC 82 ms
77,904 KB
testcase_45 AC 81 ms
77,784 KB
testcase_46 AC 83 ms
78,216 KB
testcase_47 AC 102 ms
77,996 KB
testcase_48 AC 79 ms
77,980 KB
testcase_49 AC 81 ms
78,024 KB
testcase_50 AC 79 ms
77,764 KB
testcase_51 AC 82 ms
77,944 KB
testcase_52 AC 81 ms
77,888 KB
testcase_53 AC 81 ms
77,844 KB
testcase_54 AC 82 ms
78,412 KB
testcase_55 AC 81 ms
78,096 KB
testcase_56 AC 83 ms
77,936 KB
testcase_57 AC 82 ms
77,888 KB
testcase_58 AC 79 ms
77,832 KB
testcase_59 AC 85 ms
77,808 KB
testcase_60 AC 83 ms
77,888 KB
testcase_61 AC 82 ms
78,076 KB
testcase_62 AC 83 ms
78,116 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

def factorial_inverse(n, mod):
    fac = [1] * (n+1)
    inv = [1] * (n+1)
    finv = [1] * (n+1)
    
    for i in range(2, n+1):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i] * (mod//i) % mod
        finv[i] = finv[i-1] * inv[i] % mod
        
    return fac, finv

fac, finv = factorial_inverse(10**5+100, MOD)
p = []
n = N-1
for i in range(N):
    p.append(fac[n] * (finv[i] * finv[n - i] % MOD) % MOD)

ans = 0
for i in range(N):
    ans += (A[i] * p[i]) % MOD
    ans %= MOD
print(ans)
0