結果

問題 No.1510 Simple Integral
ユーザー Re_menal2Re_menal2
提出日時 2021-05-14 23:07:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 963 bytes
コンパイル時間 1,644 ms
コンパイル使用メモリ 165,964 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-10 02:29:33
合計ジャッジ時間 3,084 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 WA -
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,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 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
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 #

#include <bits/stdc++.h>
using namespace std;

const int MM = 998244353;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
  int N; cin >> N;
  vector<long long> A(N+1); for(int i=0;i<N;i++) cin >> A[i];

  long long ans=0;
  for (int i=0; i<N; i++) {
    long long ti1 = (A[i] * A[i]) % MM;
    long long quo=1;
    
    //mod for each terms
    for (int j=0; j<N; j++) {
      if (j == i) continue;
      long long ti2 = (A[j] * A[j]) % MM;
      long long mm = (ti1 - ti2) % MM;
      if (mm < 0) mm += MM;
      quo = (modinv(mm, MM) * quo) % MM;
    }
    long long mmod = (quo * modinv(A[i], MM)) % MM;
    
    ans = (ans + mmod) % MM;
  }
  if (N-1 % 2 == 1) ans += MM;
  cout << ans << endl;
}
0