結果

問題 No.1325 Subsequence Score
ユーザー shotoyooshotoyoo
提出日時 2020-12-22 00:15:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 285 ms / 2,000 ms
コード長 1,119 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 81,828 KB
実行使用メモリ 205,756 KB
最終ジャッジ日時 2023-10-21 12:11:26
合計ジャッジ時間 5,652 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,376 KB
testcase_01 AC 40 ms
53,376 KB
testcase_02 AC 38 ms
53,376 KB
testcase_03 AC 50 ms
62,180 KB
testcase_04 AC 40 ms
53,376 KB
testcase_05 AC 50 ms
62,180 KB
testcase_06 AC 40 ms
53,376 KB
testcase_07 AC 48 ms
62,180 KB
testcase_08 AC 39 ms
53,376 KB
testcase_09 AC 43 ms
53,376 KB
testcase_10 AC 39 ms
53,376 KB
testcase_11 AC 39 ms
53,376 KB
testcase_12 AC 41 ms
53,376 KB
testcase_13 AC 281 ms
183,864 KB
testcase_14 AC 122 ms
109,920 KB
testcase_15 AC 259 ms
187,208 KB
testcase_16 AC 280 ms
205,756 KB
testcase_17 AC 153 ms
117,444 KB
testcase_18 AC 113 ms
105,584 KB
testcase_19 AC 285 ms
184,564 KB
testcase_20 AC 87 ms
89,980 KB
testcase_21 AC 131 ms
107,508 KB
testcase_22 AC 159 ms
119,872 KB
testcase_23 AC 282 ms
184,608 KB
testcase_24 AC 283 ms
184,608 KB
testcase_25 AC 282 ms
184,568 KB
testcase_26 AC 281 ms
184,568 KB
testcase_27 AC 283 ms
184,568 KB
testcase_28 AC 39 ms
53,376 KB
testcase_29 AC 38 ms
53,376 KB
testcase_30 AC 38 ms
53,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))
M = 998244353

### 素数の逆元とCombination

N = n+10 # 必要なテーブルサイズ
g1 = [0] * (N+1) # 元テーブル
g2 = [0] * (N+1) #逆元テーブル
inverse = [0] * (N+1) #逆元テーブル計算用テーブル
g1[0] = g1[1] = g2[0] = g2[1] = 1
inverse[0], inverse[1] = [0, 1] 
for i in range( 2, N + 1 ):
    g1[i] = ( g1[i-1] * i ) % M 
    inverse[i] = ( -inverse[M % i] * (M//i) ) % M # ai+b==0 mod M <=> i==-b*a^(-1) <=> i^(-1)==-b^(-1)*aより
    g2[i] = (g2[i-1] * inverse[i]) % M 
def cmb(n, r, M):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return ((g1[n] * g2[r] % M) * g2[n-r]) % M
def perm(n, r, M):
    if (r<0 or r>n):
        return 0
    return (g1[n] * g2[n-r]) % M
ans = 0
vs = [1]
v = 1
for i in range(N):
    v *= 2
    v %= M
    vs.append(v)
# ans = vs[n-1] * a[0]
for i in range(1,n+1):
    ans += a[i-1] * ((i-1) * vs[i-2] + vs[i-1]) * vs[n-i]
    ans %= M
print(ans)
0