結果

問題 No.1510 Simple Integral
ユーザー 遭難者遭難者
提出日時 2021-03-31 11:56:06
言語 Java
(openjdk 23)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 980 bytes
コンパイル時間 2,532 ms
コンパイル使用メモリ 80,124 KB
実行使用メモリ 58,112 KB
最終ジャッジ日時 2024-09-14 22:57:46
合計ジャッジ時間 10,414 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 1 WA * 42
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        var sc = new Scanner(System.in);
        int n = sc.nextInt();
        var a = new int[n];
        Arrays.setAll(a , i -> sc.nextInt());
        long s = 0;
        for (int i = 0; i < n; i++) {
            long t = a[i];
            for (int j = 0; j < n; j++) {
                if (i != j) {
                    t *= (a[j] * a[j] - a[i] * a[i]) % mod;
                    t %= mod;
                }
            }
            if (t < 0)
                t += mod;
            s += inv(t);
            s %= mod;
        }
        System.out.println(s);
    }

    public static long mod = 998244353;

    static long inv(long a) {
        return mp(a, mod - 2);
    }

    static long mp(long a, long b) {
        if (b == 0)
            return 1;
        if ((b & 1) == 1)
            return (a * mp(a, b - 1)) % mod;
        return mp((a * a) % mod, b >> 1);
    }
}
0