結果

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

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
001sample.txt AC 22 ms
5,416 KB
002sample.txt AC 22 ms
5,412 KB
003sample.txt AC 22 ms
5,412 KB
LEARGE_case1.txt AC 308 ms
21,100 KB
LEARGE_case2.txt AC 306 ms
21,104 KB
LEARGE_case3.txt AC 310 ms
21,100 KB
LEARGE_case4.txt AC 305 ms
21,096 KB
LEARGE_case5.txt AC 310 ms
21,100 KB
LEARGE_case6.txt AC 304 ms
21,104 KB
LEARGE_case7.txt AC 305 ms
21,100 KB
LEARGE_case8.txt AC 311 ms
21,104 KB
LEARGE_case9.txt AC 305 ms
21,100 KB
LEARGE_case10.txt AC 308 ms
21,104 KB
LEARGE_case11.txt AC 305 ms
21,100 KB
LEARGE_case12.txt AC 305 ms
21,104 KB
LEARGE_case13.txt AC 305 ms
21,104 KB
LEARGE_case14.txt AC 312 ms
21,100 KB
LEARGE_case15.txt AC 324 ms
21,104 KB
LEARGE_case16.txt AC 307 ms
21,104 KB
LEARGE_case17.txt AC 308 ms
21,100 KB
LEARGE_case18.txt AC 307 ms
21,104 KB
LEARGE_case19.txt AC 305 ms
21,104 KB
LEARGE_case20.txt AC 306 ms
21,100 KB
RANDOM_case1.txt AC 225 ms
16,492 KB
RANDOM_case2.txt AC 85 ms
8,812 KB
RANDOM_case3.txt AC 197 ms
14,872 KB
RANDOM_case4.txt AC 184 ms
14,236 KB
RANDOM_case5.txt AC 302 ms
20,648 KB
RANDOM_case6.txt AC 278 ms
19,056 KB
RANDOM_case7.txt AC 58 ms
7,240 KB
RANDOM_case8.txt AC 80 ms
8,560 KB
RANDOM_case9.txt AC 225 ms
16,624 KB
RANDOM_case10.txt AC 107 ms
10,084 KB
RANDOM_case11.txt AC 189 ms
14,560 KB
RANDOM_case12.txt AC 138 ms
11,716 KB
RANDOM_case13.txt AC 305 ms
21,104 KB
RANDOM_case14.txt AC 52 ms
6,912 KB
RANDOM_case15.txt AC 272 ms
19,044 KB
RANDOM_case16.txt AC 285 ms
19,952 KB
RANDOM_case17.txt AC 187 ms
14,280 KB
RANDOM_case18.txt AC 51 ms
6,896 KB
RANDOM_case19.txt AC 67 ms
7,852 KB
RANDOM_case20.txt AC 179 ms
13,948 KB
SMALL_case1.txt AC 23 ms
5,412 KB
SMALL_case2.txt AC 22 ms
5,416 KB
SMALL_case3.txt AC 22 ms
5,416 KB
SMALL_case4.txt AC 22 ms
5,412 KB
SMALL_case5.txt AC 23 ms
5,416 KB
SMALL_case6.txt AC 22 ms
5,412 KB
SMALL_case7.txt AC 22 ms
5,412 KB
SMALL_case8.txt AC 22 ms
5,416 KB
SMALL_case9.txt AC 22 ms
5,412 KB
SMALL_case10.txt AC 22 ms
5,412 KB
SMALL_case11.txt AC 22 ms
5,416 KB
SMALL_case12.txt AC 22 ms
5,412 KB
SMALL_case13.txt AC 22 ms
5,416 KB
SMALL_case14.txt AC 22 ms
5,416 KB
SMALL_case15.txt AC 23 ms
5,412 KB
SMALL_case16.txt AC 22 ms
5,412 KB
SMALL_case17.txt AC 22 ms
5,412 KB
SMALL_case18.txt AC 21 ms
5,412 KB
SMALL_case19.txt AC 22 ms
5,412 KB
SMALL_case20.txt AC 22 ms
5,416 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