結果

問題 No.797 Noelちゃんとピラミッド
ユーザー pasoconhoshii
提出日時 2019-03-15 22:39:10
言語 Python3
(3.7.1 + numpy 1.14.5 + scipy 1.1.0)
結果
AC  
実行時間 301 ms
コード長 801 Byte
コンパイル時間 46 ms
使用メモリ 21,104 KB
最終ジャッジ日時 2019-06-28 11:37:31

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
001sample.txt AC 19 ms
6,872 KB
002sample.txt AC 19 ms
8,912 KB
003sample.txt AC 20 ms
8,912 KB
LEARGE_case1.txt AC 292 ms
21,096 KB
LEARGE_case2.txt AC 292 ms
21,096 KB
LEARGE_case3.txt AC 297 ms
21,092 KB
LEARGE_case4.txt AC 293 ms
21,092 KB
LEARGE_case5.txt AC 297 ms
21,096 KB
LEARGE_case6.txt AC 293 ms
21,100 KB
LEARGE_case7.txt AC 296 ms
21,100 KB
LEARGE_case8.txt AC 301 ms
21,096 KB
LEARGE_case9.txt AC 295 ms
21,096 KB
LEARGE_case10.txt AC 292 ms
21,100 KB
LEARGE_case11.txt AC 295 ms
21,096 KB
LEARGE_case12.txt AC 297 ms
21,100 KB
LEARGE_case13.txt AC 296 ms
21,100 KB
LEARGE_case14.txt AC 294 ms
21,100 KB
LEARGE_case15.txt AC 294 ms
21,100 KB
LEARGE_case16.txt AC 292 ms
21,100 KB
LEARGE_case17.txt AC 298 ms
21,100 KB
LEARGE_case18.txt AC 295 ms
21,096 KB
LEARGE_case19.txt AC 291 ms
21,100 KB
LEARGE_case20.txt AC 297 ms
21,100 KB
RANDOM_case1.txt AC 219 ms
16,492 KB
RANDOM_case2.txt AC 79 ms
8,808 KB
RANDOM_case3.txt AC 185 ms
14,868 KB
RANDOM_case4.txt AC 177 ms
14,232 KB
RANDOM_case5.txt AC 288 ms
20,644 KB
RANDOM_case6.txt AC 266 ms
19,052 KB
RANDOM_case7.txt AC 53 ms
7,240 KB
RANDOM_case8.txt AC 78 ms
8,556 KB
RANDOM_case9.txt AC 212 ms
16,624 KB
RANDOM_case10.txt AC 99 ms
10,076 KB
RANDOM_case11.txt AC 179 ms
14,556 KB
RANDOM_case12.txt AC 133 ms
11,712 KB
RANDOM_case13.txt AC 290 ms
21,104 KB
RANDOM_case14.txt AC 46 ms
6,904 KB
RANDOM_case15.txt AC 258 ms
19,044 KB
RANDOM_case16.txt AC 274 ms
19,948 KB
RANDOM_case17.txt AC 176 ms
14,272 KB
RANDOM_case18.txt AC 47 ms
6,896 KB
RANDOM_case19.txt AC 62 ms
8,920 KB
RANDOM_case20.txt AC 172 ms
13,948 KB
SMALL_case1.txt AC 20 ms
6,872 KB
SMALL_case2.txt AC 20 ms
6,868 KB
SMALL_case3.txt AC 19 ms
6,868 KB
SMALL_case4.txt AC 20 ms
6,868 KB
SMALL_case5.txt AC 20 ms
6,868 KB
SMALL_case6.txt AC 20 ms
6,868 KB
SMALL_case7.txt AC 19 ms
6,872 KB
SMALL_case8.txt AC 20 ms
6,868 KB
SMALL_case9.txt AC 19 ms
6,872 KB
SMALL_case10.txt AC 20 ms
6,868 KB
SMALL_case11.txt AC 20 ms
6,868 KB
SMALL_case12.txt AC 19 ms
6,872 KB
SMALL_case13.txt AC 19 ms
6,872 KB
SMALL_case14.txt AC 19 ms
6,868 KB
SMALL_case15.txt AC 19 ms
6,872 KB
SMALL_case16.txt AC 19 ms
6,872 KB
SMALL_case17.txt AC 19 ms
6,872 KB
SMALL_case18.txt AC 19 ms
6,872 KB
SMALL_case19.txt AC 19 ms
6,872 KB
SMALL_case20.txt AC 19 ms
6,872 KB
テストケース一括ダウンロード

ソースコード

diff #
N = int(input())
A = list(map(int, input().split()))

mod = 10**9+7
factorial = [1]
for n in range(1, N+1):
    factorial.append( factorial[n-1] * n % mod)

invFact = [0] * (N+1)
invFact[N] = pow(factorial[N], mod-2, mod)

for n in range(N-2+1, -1, -1):
    invFact[n] = invFact[n+1] * (n+1) % mod

def combi(n,m):
    try:
        return factorial[n] * invFact[m] * invFact[n-m] % mod
    except:
        print(n, m)

# print(factorial, invFact)
coeff = [0] * (N)
for i in range(N):
    # coeff[i] = combi( max(N-i-1, i) , N-1 - max(N-i-1,i))
    coeff[i]  =  factorial[N-1] * invFact[  max(N-i-1, i) ] * invFact[ N-1 - max(N-i-1,i)]  % mod
    # print(i, max(N-i-1, i), N-1-max(N-i-1,i), coeff[i])

# print(coeff)
ans = 0

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