結果

問題 No.797 Noelちゃんとピラミッド
ユーザー 双六双六
提出日時 2020-07-28 01:03:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 148 ms / 2,000 ms
コード長 937 bytes
コンパイル時間 632 ms
コンパイル使用メモリ 86,816 KB
実行使用メモリ 96,876 KB
最終ジャッジ日時 2023-09-11 06:15:34
合計ジャッジ時間 12,502 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
70,944 KB
testcase_01 AC 99 ms
70,944 KB
testcase_02 AC 95 ms
71,288 KB
testcase_03 AC 146 ms
96,588 KB
testcase_04 AC 145 ms
96,520 KB
testcase_05 AC 141 ms
96,788 KB
testcase_06 AC 142 ms
96,876 KB
testcase_07 AC 148 ms
96,664 KB
testcase_08 AC 141 ms
96,696 KB
testcase_09 AC 146 ms
96,796 KB
testcase_10 AC 145 ms
96,592 KB
testcase_11 AC 145 ms
96,640 KB
testcase_12 AC 141 ms
96,588 KB
testcase_13 AC 147 ms
96,620 KB
testcase_14 AC 144 ms
96,608 KB
testcase_15 AC 148 ms
96,852 KB
testcase_16 AC 146 ms
96,720 KB
testcase_17 AC 144 ms
96,644 KB
testcase_18 AC 143 ms
96,820 KB
testcase_19 AC 144 ms
96,624 KB
testcase_20 AC 145 ms
96,860 KB
testcase_21 AC 144 ms
96,548 KB
testcase_22 AC 145 ms
96,612 KB
testcase_23 AC 129 ms
87,440 KB
testcase_24 AC 113 ms
79,056 KB
testcase_25 AC 126 ms
86,160 KB
testcase_26 AC 129 ms
84,972 KB
testcase_27 AC 147 ms
96,360 KB
testcase_28 AC 138 ms
94,248 KB
testcase_29 AC 112 ms
77,664 KB
testcase_30 AC 111 ms
79,092 KB
testcase_31 AC 129 ms
87,512 KB
testcase_32 AC 120 ms
80,568 KB
testcase_33 AC 129 ms
86,000 KB
testcase_34 AC 121 ms
82,804 KB
testcase_35 AC 145 ms
96,648 KB
testcase_36 AC 111 ms
77,656 KB
testcase_37 AC 140 ms
93,912 KB
testcase_38 AC 140 ms
95,912 KB
testcase_39 AC 126 ms
86,144 KB
testcase_40 AC 109 ms
77,448 KB
testcase_41 AC 109 ms
77,600 KB
testcase_42 AC 126 ms
84,908 KB
testcase_43 AC 98 ms
71,304 KB
testcase_44 AC 95 ms
71,184 KB
testcase_45 AC 96 ms
71,052 KB
testcase_46 AC 101 ms
71,272 KB
testcase_47 AC 99 ms
71,360 KB
testcase_48 AC 96 ms
71,368 KB
testcase_49 AC 99 ms
71,276 KB
testcase_50 AC 102 ms
71,100 KB
testcase_51 AC 101 ms
71,380 KB
testcase_52 AC 100 ms
71,212 KB
testcase_53 AC 97 ms
71,276 KB
testcase_54 AC 97 ms
71,376 KB
testcase_55 AC 98 ms
71,168 KB
testcase_56 AC 99 ms
71,376 KB
testcase_57 AC 98 ms
71,112 KB
testcase_58 AC 98 ms
71,172 KB
testcase_59 AC 99 ms
71,184 KB
testcase_60 AC 98 ms
71,176 KB
testcase_61 AC 98 ms
71,180 KB
testcase_62 AC 100 ms
71,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

class Combination(object):
	def __init__(self, N, con):
		self.fac = [0] * (N + 1)
		self.inv = [0] * (N + 1)
		self.finv = [0] * (N + 1)
		self.fac[0], self.fac[1] = 1, 1
		self.inv[1] = 1
		self.finv[0], self.finv[1] = 1, 1

		# 前計算
		for i in range(2, N + 1):
			self.fac[i] = self.fac[i - 1] * i % con
			self.inv[i] = self.inv[con % i] * (con - (con // i)) % con
			self.finv[i] = self.finv[i - 1] * self.inv[i] % con

	def com(self, N, k):
		return (self.fac[N] * self.finv[k] * self.finv[N - k]) % con

#処理内容
def main():
	N = int(input())
	A = getlist()
	ans = 0
	Com = Combination(N - 1, con)
	for i in range(N):
		ans += A[i] * Com.com(N - 1, i)
		ans %= con

	print(ans)


if __name__ == '__main__':
	main()
0