結果

問題 No.1510 Simple Integral
ユーザー NoneNone
提出日時 2021-05-14 23:32:21
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 2,192 bytes
コンパイル時間 381 ms
コンパイル使用メモリ 82,372 KB
実行使用メモリ 70,712 KB
最終ジャッジ日時 2024-04-10 04:06:46
合計ジャッジ時間 3,940 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
56,420 KB
testcase_01 AC 38 ms
54,344 KB
testcase_02 AC 38 ms
54,672 KB
testcase_03 AC 39 ms
55,048 KB
testcase_04 AC 39 ms
54,716 KB
testcase_05 RE -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 45 ms
63,608 KB
testcase_24 AC 44 ms
63,412 KB
testcase_25 AC 46 ms
64,060 KB
testcase_26 AC 45 ms
62,916 KB
testcase_27 AC 45 ms
63,732 KB
testcase_28 AC 46 ms
63,980 KB
testcase_29 AC 47 ms
64,280 KB
testcase_30 AC 48 ms
62,680 KB
testcase_31 AC 45 ms
62,880 KB
testcase_32 AC 46 ms
64,068 KB
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 WA -
testcase_44 WA -
testcase_45 RE -
権限があれば一括ダウンロードができます

ソースコード

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
            tmp+=pow(evaluation(division(g,b),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