結果
問題 | No.1510 Simple Integral |
ユーザー | magsta |
提出日時 | 2021-05-07 20:58:02 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,963 bytes |
コンパイル時間 | 1,109 ms |
コンパイル使用メモリ | 95,256 KB |
実行使用メモリ | 27,136 KB |
最終ジャッジ日時 | 2024-09-15 08:43:10 |
合計ジャッジ時間 | 10,430 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 105 ms
26,880 KB |
testcase_01 | AC | 98 ms
26,880 KB |
testcase_02 | AC | 96 ms
27,008 KB |
testcase_03 | AC | 100 ms
26,880 KB |
testcase_04 | AC | 98 ms
27,008 KB |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
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 | 111 ms
26,880 KB |
testcase_24 | AC | 109 ms
26,752 KB |
testcase_25 | AC | 116 ms
27,008 KB |
testcase_26 | AC | 113 ms
26,880 KB |
testcase_27 | AC | 108 ms
26,880 KB |
testcase_28 | AC | 110 ms
26,880 KB |
testcase_29 | AC | 105 ms
26,880 KB |
testcase_30 | AC | 103 ms
27,008 KB |
testcase_31 | AC | 102 ms
26,880 KB |
testcase_32 | AC | 102 ms
26,880 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 | RE | - |
testcase_44 | RE | - |
testcase_45 | RE | - |
ソースコード
#include <iostream> #include <string> #include <algorithm> #include <utility> #include <cmath> #include <cstdlib> #include <map> #include <set> #include <queue> #include <vector> using namespace std; #define PAIR pair<long long, long long> #define MOD 998244353 const int MAX = 1000000; long long fac[MAX], finv[MAX], inv[MAX]; void COMinit(long long mod) { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % mod; inv[i] = mod - inv[mod % i] * (mod / i) % mod; finv[i] = finv[i - 1] * inv[i] % mod; } } long long COM(long long n, long long k, long long mod) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % mod) % mod; } 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) { long long b = mod, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= mod; if (u < 0) u += mod; return u; } int main() { COMinit(MOD); long long N; cin >> N; vector<long long> A(N); for (int i = 0; i < N; i++) cin >> A[i]; sort(A.begin(), A.end()); vector<PAIR> B; for (int i = 0; i < N; i++) { if (i == 0) B.emplace_back(A[i], 1); else { if (B[B.size() - 1].first == A[i]) B[B.size() - 1].second--; else B.emplace_back(A[i], 1); } } long long n = B.size(); long long sum = 0; for (long long i = 0; i < n; i++) { long long Q = 1; for (long long j = 0; j < n; j++) { if (i == j) continue; Q = Q * modpow(((B[j].first * B[j].first - B[i].first * B[i].first) % MOD + MOD) % MOD, B[j].second, MOD) % MOD; } vector<long long> g(B[i].second, 0); g[0] = -1; for (long long j = 0; j < n; j++) { if (i == j) continue; for (long long k = 0; k < B[j].second; k++) { vector<long long> g_(B[i].second, 0); for (long long l = 0; l < B[i].second; l++) { if (l == 0) g_[l] = g[l] * ((B[j].first * B[j].first - B[i].first * B[i].first) % MOD) % MOD; else g_[l] = (g[l] * ((B[j].first * B[j].first - B[i].first * B[i].first) % MOD) % MOD + g[l - 1]) % MOD; } g = g_; } } g[0] = 0; vector<long long> g_(B[i].second, 0); g_[0] = 1; long long Q_pow = 1; for (long long j = 0; j < B[i].second; j++) { if (j != 0) { vector<long long> g_2(B[i].second, 0); for (long long k = 0; k < B[i].second; k++) { for (long long l = 0; l < B[i].second; l++) { if (k + l >= B[i].second) continue; g_2[k + l] = (g_2[k + l] + g[k] * g_[l]) % MOD; } } g_ = g_2; } Q_pow = (Q_pow * Q) % MOD; sum += ((g_[j] * modinv(Q_pow, MOD) % MOD) * COM(2 * B[i].second - 2 * j - 2, B[i].second - j - 1, MOD) % MOD) * modinv(modpow(2 * B[i].first, 2 * B[i].second - 2 * j - 1, MOD), MOD) * 2 % MOD; } } cout << sum % MOD << endl; }