結果

問題 No.1510 Simple Integral
ユーザー NoneNone
提出日時 2021-05-14 23:33:38
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,210 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 82,436 KB
実行使用メモリ 77,068 KB
最終ジャッジ日時 2024-04-10 04:09:03
合計ジャッジ時間 4,374 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
55,228 KB
testcase_01 AC 40 ms
54,796 KB
testcase_02 AC 41 ms
54,700 KB
testcase_03 AC 41 ms
55,048 KB
testcase_04 AC 44 ms
54,944 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 48 ms
63,980 KB
testcase_24 AC 50 ms
63,132 KB
testcase_25 AC 49 ms
63,080 KB
testcase_26 AC 48 ms
64,032 KB
testcase_27 AC 49 ms
63,652 KB
testcase_28 AC 49 ms
63,652 KB
testcase_29 AC 49 ms
64,368 KB
testcase_30 AC 49 ms
63,100 KB
testcase_31 AC 49 ms
63,840 KB
testcase_32 AC 49 ms
63,288 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #


def convolution(F,a):
    """
    return: f(x)*(x-a)
    """
    _N=len(F)
    res=[0]+F[:]
    for i in range(_N)[::-1]:
        res[i]+=F[i]*(-a)
        res[i]%=MOD
    return res

def division(F,a):
    """
    return: f(x)/(x-a)の 商, 余り
    """
    res=[0]*len(F)
    res[-1]=F[-1]
    for i in range(len(F)-1)[::-1]:
        res[i]=(F[i]+a*res[i+1])
        res[i]%=MOD
    return res[1:], res[0]

def evaluation(F,a):
    """
    :return: F(a)
    """
    q,r=division(F,a)
    return r

def differentiate(F):
    """
    O(N)
    """
    res=[0]*(len(F)-1)
    for i in range(len(F)):
        res[i-1]=F[i]*i
    return res

def FindFunction(A,B):
    def gcd_ext(a0,b0):
        a,b=abs(a0),abs(b0)
        sign_a,sing_b=(a0>0)-(a0<0),(b0>0)-(b0<0)
        x0,y0,x,y=0,1,1,0
        while b!=0:
            q=a//b
            a,b=b,a%b
            x0,y0,x,y=x-q*x0,y-q*y0,x0,y0
        return (x*sign_a,y*sing_b)

    def mod_inv(a,MOD):
        """
        gcd(a,MOD)=1 を満たす必要あり
        """
        x,y=gcd_ext(a,MOD)
        return x%MOD

    _N=len(A)
    F=[1]
    for a in A:
        F=convolution(F,a)
    Fs=[]
    for a in A:
        q,r=division(F,a)
        Fs.append(q)
    C=[]
    for i,b in enumerate(B):
        val=evaluation(Fs[i],A[i])
        C.append(b*mod_inv(val,MOD)%MOD)
    res=[0]*(_N)
    for c,F in zip(C,Fs):
        for i,p in enumerate(F):
            if i>=_N:
                continue
            res[i]+=c*p
            res[i]%=MOD
    return res

#######################################################################


from collections import Counter

MOD=998244353

N=int(input())
A=list(map(int, input().split()))
f=[1]
for a in A:
    f=convolution(f,a)
    f=convolution(f,-a)
C=[]
P=Counter(A).items()
for a,cnt in P:
    g=f[:]
    for _ in range(cnt):
        g,_=division(g,a)
    tmp=0
    if cnt!=1:
        for b,_ in P:
            if a==b:continue
            q,r=division(g,b)
            tmp+=pow(evaluation(q,b)*pow((a-b),cnt-1,MOD),MOD-2,MOD)
            tmp%=MOD
    else:
        tmp=pow(evaluation(g,a),MOD-2,MOD)


    C.append(tmp)

res=0
sign=pow(-1,(N-1)%2)
for c in C:
    res+=c*sign
    res%=MOD
print(res*2%MOD)
0