結果
問題 | No.1510 Simple Integral |
ユーザー | magsta |
提出日時 | 2021-05-07 21:10:23 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,969 bytes |
コンパイル時間 | 1,285 ms |
コンパイル使用メモリ | 95,388 KB |
実行使用メモリ | 26,880 KB |
最終ジャッジ日時 | 2024-09-15 08:52:41 |
合計ジャッジ時間 | 7,431 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge6 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 99 ms
26,880 KB |
testcase_01 | AC | 103 ms
26,864 KB |
testcase_02 | AC | 104 ms
26,752 KB |
testcase_03 | AC | 100 ms
26,880 KB |
testcase_04 | AC | 96 ms
26,852 KB |
testcase_05 | WA | - |
testcase_06 | AC | 104 ms
26,880 KB |
testcase_07 | AC | 101 ms
26,880 KB |
testcase_08 | AC | 104 ms
26,752 KB |
testcase_09 | AC | 98 ms
26,880 KB |
testcase_10 | AC | 100 ms
26,752 KB |
testcase_11 | AC | 107 ms
26,876 KB |
testcase_12 | AC | 104 ms
26,880 KB |
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 | AC | 89 ms
26,752 KB |
testcase_24 | AC | 98 ms
26,880 KB |
testcase_25 | AC | 95 ms
26,872 KB |
testcase_26 | AC | 98 ms
26,764 KB |
testcase_27 | AC | 100 ms
26,880 KB |
testcase_28 | AC | 102 ms
26,856 KB |
testcase_29 | AC | 101 ms
26,752 KB |
testcase_30 | AC | 100 ms
26,880 KB |
testcase_31 | AC | 97 ms
26,880 KB |
testcase_32 | AC | 99 ms
26,864 KB |
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 | AC | 91 ms
26,880 KB |
testcase_44 | AC | 93 ms
26,880 KB |
testcase_45 | WA | - |
ソースコード
#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) % 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; }