結果

問題 No.2651 [Cherry 6th Tune B] $\mathbb{C}$omplex комбинат
ユーザー 👑 hitonanodehitonanode
提出日時 2024-03-10 18:22:54
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 509 ms / 2,500 ms
コード長 1,637 bytes
コンパイル時間 833 ms
コンパイル使用メモリ 85,696 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-10 18:23:11
合計ジャッジ時間 16,624 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 463 ms
6,676 KB
testcase_03 AC 432 ms
6,676 KB
testcase_04 AC 431 ms
6,676 KB
testcase_05 AC 430 ms
6,676 KB
testcase_06 AC 431 ms
6,676 KB
testcase_07 AC 459 ms
6,676 KB
testcase_08 AC 431 ms
6,676 KB
testcase_09 AC 431 ms
6,676 KB
testcase_10 AC 453 ms
6,676 KB
testcase_11 AC 431 ms
6,676 KB
testcase_12 AC 430 ms
6,676 KB
testcase_13 AC 436 ms
6,676 KB
testcase_14 AC 428 ms
6,676 KB
testcase_15 AC 456 ms
6,676 KB
testcase_16 AC 431 ms
6,676 KB
testcase_17 AC 431 ms
6,676 KB
testcase_18 AC 456 ms
6,676 KB
testcase_19 AC 429 ms
6,676 KB
testcase_20 AC 509 ms
6,676 KB
testcase_21 AC 128 ms
6,676 KB
testcase_22 AC 226 ms
6,676 KB
testcase_23 AC 291 ms
6,676 KB
testcase_24 AC 359 ms
6,676 KB
testcase_25 AC 25 ms
6,676 KB
testcase_26 AC 218 ms
6,676 KB
testcase_27 AC 423 ms
6,676 KB
testcase_28 AC 313 ms
6,676 KB
testcase_29 AC 157 ms
6,676 KB
testcase_30 AC 30 ms
6,676 KB
testcase_31 AC 355 ms
6,676 KB
testcase_32 AC 54 ms
6,676 KB
testcase_33 AC 322 ms
6,676 KB
testcase_34 AC 195 ms
6,676 KB
testcase_35 AC 411 ms
6,676 KB
testcase_36 AC 445 ms
6,676 KB
testcase_37 AC 432 ms
6,676 KB
testcase_38 AC 431 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

#include <atcoder/modint>
using mint = atcoder::modint998244353;

struct C {
    mint real;
    mint imag;

    C() : real(0), imag(0) {}

    C(mint real, mint imag) : real(real), imag(imag) {}

    C operator+(const C &rhs) const {
        return C(real + rhs.real, imag + rhs.imag);
    }

    C operator-(const C &rhs) const {
        return C(real - rhs.real, imag - rhs.imag);
    }

    C operator*(const C &rhs) const {
        return C(real * rhs.real - imag * rhs.imag, real * rhs.imag + imag * rhs.real);
    }

    C operator/(const C &rhs) const {
        mint norm = rhs.real * rhs.real + rhs.imag * rhs.imag;
        mint real_ = real * rhs.real + imag * rhs.imag;
        mint imag_ = imag * rhs.real - real * rhs.imag;
        return C(real_ / norm, imag_ / norm);
    }

    C conj() const {
        return C(real, -imag);
    }
};

// i != j |zi|^2 / |zj|^2 - (zi / zi*) (zj* / zj)

int main() {

    int T;
    cin >> T;
    while (T--) {
        int N;
        cin >> N;

        C sum_of_l2;
        C sum_of_inv_of_l2;
        C sum_of_z_div_z_conj;
        C sum_of_z_conj_div_z;
        while (N--) {
            int x, y;
            cin >> x >> y;
            C z(x, y);
            sum_of_l2 = sum_of_l2 + z * z.conj();
            sum_of_inv_of_l2 = sum_of_inv_of_l2 + C(1, 0) / (z * z.conj());

            sum_of_z_div_z_conj = sum_of_z_div_z_conj + z / z.conj();
            sum_of_z_conj_div_z = sum_of_z_conj_div_z + z.conj() / z;
        }

        cout << (sum_of_l2 * sum_of_inv_of_l2 - sum_of_z_div_z_conj * sum_of_z_conj_div_z).real.val() << '\n';
    }
}
0