結果

問題 No.1325 Subsequence Score
ユーザー jensenjensen
提出日時 2021-01-03 23:12:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 819 bytes
コンパイル時間 118 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 17,952 KB
最終ジャッジ日時 2024-04-21 18:04:23
合計ジャッジ時間 4,415 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
17,952 KB
testcase_01 AC 29 ms
10,752 KB
testcase_02 AC 30 ms
10,752 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import factorial
n=int(input())
a=list(map(int,input().split()))
point=0

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def cm(l,i,j):
    a = cmb(i,j-1)
    b = 2**(len(l)-i-1)
    return int(a*b)

for i in range(n):
    for j in range(1,i+2):
        point+=a[i]*j*cm(a,i,j)
print(point%998244353)
0