結果
| 問題 |
No.2651 [Cherry 6th Tune B] $\mathbb{C}$omplex комбинат
|
| コンテスト | |
| ユーザー |
hitonanode
|
| 提出日時 | 2024-03-10 18:22:54 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 486 ms / 2,500 ms |
| コード長 | 1,637 bytes |
| コンパイル時間 | 1,106 ms |
| コンパイル使用メモリ | 85,704 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-09-29 21:44:09 |
| 合計ジャッジ時間 | 17,272 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 39 |
ソースコード
#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';
}
}
hitonanode