結果

問題 No.2651 [Cherry 6th Tune B] $\mathbb{C}$omplex комбинат
ユーザー coindarwcoindarw
提出日時 2024-02-28 10:33:46
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 278 ms / 2,500 ms
コード長 1,689 bytes
コンパイル時間 7,079 ms
コンパイル使用メモリ 312,772 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-28 10:34:01
合計ジャッジ時間 14,438 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 184 ms
6,676 KB
testcase_03 AC 174 ms
6,676 KB
testcase_04 AC 174 ms
6,676 KB
testcase_05 AC 175 ms
6,676 KB
testcase_06 AC 175 ms
6,676 KB
testcase_07 AC 175 ms
6,676 KB
testcase_08 AC 174 ms
6,676 KB
testcase_09 AC 174 ms
6,676 KB
testcase_10 AC 175 ms
6,676 KB
testcase_11 AC 175 ms
6,676 KB
testcase_12 AC 175 ms
6,676 KB
testcase_13 AC 175 ms
6,676 KB
testcase_14 AC 174 ms
6,676 KB
testcase_15 AC 175 ms
6,676 KB
testcase_16 AC 175 ms
6,676 KB
testcase_17 AC 174 ms
6,676 KB
testcase_18 AC 175 ms
6,676 KB
testcase_19 AC 175 ms
6,676 KB
testcase_20 AC 259 ms
6,676 KB
testcase_21 AC 53 ms
6,676 KB
testcase_22 AC 93 ms
6,676 KB
testcase_23 AC 119 ms
6,676 KB
testcase_24 AC 145 ms
6,676 KB
testcase_25 AC 11 ms
6,676 KB
testcase_26 AC 85 ms
6,676 KB
testcase_27 AC 172 ms
6,676 KB
testcase_28 AC 128 ms
6,676 KB
testcase_29 AC 55 ms
6,676 KB
testcase_30 AC 13 ms
6,676 KB
testcase_31 AC 144 ms
6,676 KB
testcase_32 AC 23 ms
6,676 KB
testcase_33 AC 131 ms
6,676 KB
testcase_34 AC 80 ms
6,676 KB
testcase_35 AC 157 ms
6,676 KB
testcase_36 AC 278 ms
6,676 KB
testcase_37 AC 174 ms
6,676 KB
testcase_38 AC 163 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#include <atcoder/all>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(v) begin(v), end(v)
using namespace std;
using namespace atcoder;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    using mint = modint998244353;
    using P = pair<mint, mint>;
    int Q;
    cin >> Q;
    while (Q--) {
        int n;
        cin >> n;
        vector<P> z(n);
        rep(i, n) {
            int l, r;
            cin >> l >> r;
            z[i] = {l, r};
        }
        mint A = 0, B = 0, C = 0, D = 0, E = 0, F = 0, G = 0;
        rep(i, n) {
            auto [x, y] = z[i];
            mint xxyyI = mint(1) / (x * x + y * y);
            A += (2 * x * x) * xxyyI;
            B += (8 * x * y) * xxyyI;
            C += (2 * y * y) * xxyyI;
            D += x * x;
            E += y * y;
            F += x * x * xxyyI * xxyyI;
            G += y * y * xxyyI * xxyyI;
        }

        mint ans = 0;
        rep(i, n) {
            auto [a, b] = z[i];
            mint aabbI = mint(1) / (a * a + b * b);
            ans += -A * (a * a) * aabbI;
            ans += A * (b * b) * aabbI;
            ans += -B * a * b * aabbI;
            ans += C * (a * a) * aabbI;
            ans += -C * (b * b) * aabbI;
            ans += D * (a * a) * aabbI * aabbI;
            ans += D * (b * b) * aabbI * aabbI;
            ans += E * (a * a) * aabbI * aabbI;
            ans += E * (b * b) * aabbI * aabbI;
            ans += F * (a * a);
            ans += F * (b * b);
            ans += G * (a * a);
            ans += G * (b * b);
        }
        ans /= 2;
        cout << ans.val() << endl;
    }
    return 0;
}
0