結果

問題 No.1510 Simple Integral
ユーザー 정현우정현우
提出日時 2022-01-15 02:02:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,206 bytes
コンパイル時間 174 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 17,824 KB
最終ジャッジ日時 2024-04-30 21:17:12
合計ジャッジ時間 3,894 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
17,824 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
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 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#(1/pi)*(1/N)*Integral[1/(x^2+A^2)^m,{x,-Infinity,Infinity}]
#=>cal(N,A,m)

mod=998244353

def minimize(lli):
    if len(lli)==1:
        return lli
    li=lli[:]
    li.sort(key=lambda x:x[1])
    
    while True:
        if li[-1][1]==li[-2][1] and li[-1][2]==li[-2][2]:
            li[-2]=(li[-1][0]*li[-2][0]*pow(li[-1][0]+li[-2][0],-1,mod)%mod, li[-1][1],li[-1][2])
            del li[-1]
    return li


def cal(N,A,m):
    numer=1
    denom=N*pow(A,2*m-1,mod)*pow(4,m-1,mod)%mod
    for i in range(m,2*m-1):
        numer*=i
        numer%=mod
    for i in range(1,m):
        denom*=i
        denom%=mod
    
    return numer*pow(denom,-1,mod)%mod


def change(tuple_1,A2):
    N1,A1,m1=tuple_1
    if A1==A2:
        return [(N1,A1,m1+1)]
    if m1==1:
        return [(N1*(A2**2-A1**2)%mod,A1,1),(-N1*(A2**2-A1**2)%mod,A2,1)]
    else:
        tmp=change((-N1*(A2**2-A1**2)%mod, A1, m1-1), A2)
        return [(N1*(A2**2-A1**2)%mod,A1,m1)]+tmp

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

li=[(1,a[0],1)]
for i in range(1,n):
    ret=[]
    for tu in li:
        ret+=change(tu,a[i])
    li=ret[:]
    li=minimize(li)
#print(li)
ans=0
for tu in li:
    ans+=cal(*tu)
print(ans%mod)
0