結果

問題 No.1081 和の和
ユーザー rythem00359rythem00359
提出日時 2020-08-13 16:55:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 323 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,648 KB
最終ジャッジ日時 2024-04-18 01:38:16
合計ジャッジ時間 908 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,752 KB
testcase_01 AC 27 ms
10,752 KB
testcase_02 AC 25 ms
10,752 KB
testcase_03 AC 25 ms
10,752 KB
testcase_04 AC 31 ms
11,264 KB
testcase_05 AC 27 ms
10,752 KB
testcase_06 AC 30 ms
10,880 KB
testcase_07 AC 30 ms
11,392 KB
testcase_08 AC 33 ms
11,520 KB
testcase_09 AC 32 ms
11,648 KB
testcase_10 AC 34 ms
11,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]
N=int(input())
a=[*map(int,input().split())]
ans=a[0]+a[N-1]
for i in range(1,N-1):
    ans+=a[i]*(cmb(N-1,i))
print(int(ans%1000000007))
0