結果

問題 No.1325 Subsequence Score
ユーザー chineristAC
提出日時 2020-12-22 13:04:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 247 ms / 2,000 ms
コード長 734 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 82,160 KB
実行使用メモリ 175,232 KB
最終ジャッジ日時 2024-09-21 14:08:55
合計ジャッジ時間 5,872 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

def cmb(n, r, mod):#コンビネーションの高速計算 
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 998244353 #出力の制限
N = 5*10**5
g1 = [1]*(N+1) # 元テーブル
g2 = [1]*(N+1) #逆元テーブル
inverse = [1]*(N+1) #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1[i]=( ( g1[i-1] * i ) % mod )
    inverse[i]=( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2[i]=( (g2[i-1] * inverse[i]) % mod )
inverse[0]=0

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

if N==1:
    exit(print(A[0]%mod))

a = pow(2,N-2,mod)
b = pow(2,N-1,mod)
res = 0
for i in range(N):
    res += A[i] * i * a + A[i] * b
    res %= mod

print(res)
0