結果

問題 No.2651 [Cherry 6th Tune B] $\mathbb{C}$omplex комбинат
ユーザー kokoseikokosei
提出日時 2024-02-23 22:58:31
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 649 ms / 2,500 ms
コード長 1,839 bytes
コンパイル時間 3,224 ms
コンパイル使用メモリ 250,280 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-23 22:58:56
合計ジャッジ時間 24,542 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,548 KB
testcase_01 AC 3 ms
6,548 KB
testcase_02 AC 627 ms
6,548 KB
testcase_03 AC 627 ms
6,548 KB
testcase_04 AC 623 ms
6,548 KB
testcase_05 AC 625 ms
6,548 KB
testcase_06 AC 648 ms
6,548 KB
testcase_07 AC 622 ms
6,548 KB
testcase_08 AC 646 ms
6,548 KB
testcase_09 AC 625 ms
6,548 KB
testcase_10 AC 648 ms
6,548 KB
testcase_11 AC 625 ms
6,548 KB
testcase_12 AC 648 ms
6,548 KB
testcase_13 AC 624 ms
6,548 KB
testcase_14 AC 649 ms
6,548 KB
testcase_15 AC 624 ms
6,548 KB
testcase_16 AC 622 ms
6,548 KB
testcase_17 AC 623 ms
6,548 KB
testcase_18 AC 623 ms
6,548 KB
testcase_19 AC 624 ms
6,548 KB
testcase_20 AC 637 ms
6,548 KB
testcase_21 AC 188 ms
6,548 KB
testcase_22 AC 330 ms
6,548 KB
testcase_23 AC 423 ms
6,548 KB
testcase_24 AC 516 ms
6,548 KB
testcase_25 AC 37 ms
6,548 KB
testcase_26 AC 301 ms
6,548 KB
testcase_27 AC 614 ms
6,548 KB
testcase_28 AC 455 ms
6,548 KB
testcase_29 AC 195 ms
6,548 KB
testcase_30 AC 45 ms
6,548 KB
testcase_31 AC 513 ms
6,548 KB
testcase_32 AC 79 ms
6,548 KB
testcase_33 AC 497 ms
6,548 KB
testcase_34 AC 285 ms
6,548 KB
testcase_35 AC 561 ms
6,548 KB
testcase_36 AC 442 ms
6,548 KB
testcase_37 AC 622 ms
6,676 KB
testcase_38 AC 641 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using ll = long long;
using mint = atcoder::modint998244353;

int N;
pair<mint, mint> Z[301010];
mint absc(pair<mint, mint> z){
    return z.first * z.first + z.second * z.second;
}
pair<mint, mint> neg(pair<mint, mint> z){
    return make_pair(z.first, -z.second);
}
pair<mint, mint> add(pair<mint, mint> a, pair<mint, mint> b){
    return make_pair(a.first + b.first, a.second + b.second);
}
pair<mint, mint> sub(pair<mint, mint> a, pair<mint, mint> b){
    return make_pair(a.first - b.first, a.second - b.second);
}
pair<mint, mint> mul(pair<mint, mint> a, pair<mint, mint> b){
    return make_pair(
        a.first * b.first - a.second * b.second,
        a.second * b.first + a.first * b.second
    );
}
pair<mint, mint> dev(pair<mint, mint> a, pair<mint, mint> b){
    return make_pair(
        (a.first * b.first + a.second * b.second) / absc(b),
        (a.second * b.first - a.first * b.second) / absc(b)
    );
}
void solve(){
    cin >> N;
    for(int i = 0;i < N;i++){
        int x, y; cin >> x >> y;
        Z[i].first = {x};
        Z[i].second = {y};
    }
    mint sabs = 0;
    pair<mint, mint> spos, sneg;
    pair<mint, mint> ans;
    for(int i = 0;i < N;i++){
        sabs += absc(Z[i]);
    }
    for(int i = 0;i < N;i++){
        spos = add(spos, dev(Z[i], neg(Z[i])));
        sneg = add(sneg, dev(neg(Z[i]), Z[i]));
        ans = add(ans, make_pair(sabs / absc(Z[i]), mint::raw(0)));
        ans = sub(ans, dev(spos, dev(Z[i], neg(Z[i]))));
        ans = sub(ans, dev(sneg, dev(neg(Z[i]), Z[i])));
        ans = add(ans, make_pair(mint::raw(1), mint::raw(0)));
    }
    cout << ans.first.val() << "\n";
}
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t; cin >> t;
    while(t--)solve();
    return 0;
}
0