結果
| 問題 |
No.2651 [Cherry 6th Tune B] $\mathbb{C}$omplex комбинат
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-02-23 23:04:52 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 125 ms / 2,500 ms |
| コード長 | 1,273 bytes |
| コンパイル時間 | 815 ms |
| コンパイル使用メモリ | 81,428 KB |
| 最終ジャッジ日時 | 2025-02-19 20:32:44 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 39 |
ソースコード
#include<iostream>
#include<algorithm>
#include<vector>
#include<atcoder/modint>
using namespace std;
using ll=long long;
using mint=atcoder::modint998244353;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin>>T;
while(T--){
int N;
cin>>N;
vector<int>X(N),Y(N);
for(int i=0;i<N;i++)cin>>X[i]>>Y[i];
vector<mint>Z(N);
for(int i=0;i<N;i++)Z[i]=1/(mint)(X[i]*X[i]+Y[i]*Y[i]);
mint ans=0;
for(int t=0;t<2;t++){
mint xp=0,xq=0,yp=0,yq=0;
for(int i=0;i<N;i++){
if(t==0){
xp+=X[i]*X[i]+Y[i]*Y[i];
yp+=Z[i];
}else{
xp+=(X[i]*X[i]-Y[i]*Y[i])*Z[i];
xq+=-2*X[i]*Y[i]*Z[i];
yp+=(X[i]*X[i]-Y[i]*Y[i])*Z[i];
yq+=2*X[i]*Y[i]*Z[i];
}
}
ans+=(t==0?1:-1)*(xp*yp-xq*yq);
}
cout<<ans.val()<<"\n";
}
}