結果
| 問題 | 
                            No.1510 Simple Integral
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-05-14 23:32:21 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                RE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 2,192 bytes | 
| コンパイル時間 | 171 ms | 
| コンパイル使用メモリ | 82,444 KB | 
| 実行使用メモリ | 70,560 KB | 
| 最終ジャッジ日時 | 2024-10-02 05:32:23 | 
| 合計ジャッジ時間 | 3,867 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 12 WA * 9 RE * 22 | 
ソースコード
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)