結果

問題 No.1510 Simple Integral
ユーザー 정현우정현우
提出日時 2022-01-15 02:06:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,338 bytes
コンパイル時間 111 ms
コンパイル使用メモリ 13,056 KB
実行使用メモリ 46,452 KB
最終ジャッジ日時 2024-04-30 21:22:20
合計ジャッジ時間 4,037 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
17,956 KB
testcase_01 AC 30 ms
10,880 KB
testcase_02 AC 29 ms
10,880 KB
testcase_03 AC 27 ms
10,880 KB
testcase_04 AC 27 ms
10,880 KB
testcase_05 AC 26 ms
10,880 KB
testcase_06 AC 27 ms
10,880 KB
testcase_07 AC 25 ms
10,880 KB
testcase_08 AC 26 ms
11,008 KB
testcase_09 AC 26 ms
10,880 KB
testcase_10 AC 25 ms
10,880 KB
testcase_11 AC 25 ms
10,880 KB
testcase_12 AC 26 ms
10,880 KB
testcase_13 TLE -
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])
    ret=[]
    while True:
        if len(li)<2:
            ret=ret+li
            break
        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]
        else:
            ret.append(li.pop())
            


    return ret


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