結果

問題 No.2651 [Cherry 6th Tune B] $\mathbb{C}$omplex комбинат
ユーザー Nzt3Nzt3
提出日時 2024-03-01 11:55:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 161 ms / 2,500 ms
コード長 1,088 bytes
コンパイル時間 3,297 ms
コンパイル使用メモリ 204,460 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-01 11:55:51
合計ジャッジ時間 12,351 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 150 ms
6,676 KB
testcase_03 AC 148 ms
6,676 KB
testcase_04 AC 147 ms
6,676 KB
testcase_05 AC 148 ms
6,676 KB
testcase_06 AC 150 ms
6,676 KB
testcase_07 AC 148 ms
6,676 KB
testcase_08 AC 160 ms
6,676 KB
testcase_09 AC 150 ms
6,676 KB
testcase_10 AC 149 ms
6,676 KB
testcase_11 AC 149 ms
6,676 KB
testcase_12 AC 149 ms
6,676 KB
testcase_13 AC 150 ms
6,676 KB
testcase_14 AC 148 ms
6,676 KB
testcase_15 AC 149 ms
6,676 KB
testcase_16 AC 149 ms
6,676 KB
testcase_17 AC 150 ms
6,676 KB
testcase_18 AC 149 ms
6,676 KB
testcase_19 AC 149 ms
6,676 KB
testcase_20 AC 159 ms
6,676 KB
testcase_21 AC 46 ms
6,676 KB
testcase_22 AC 79 ms
6,676 KB
testcase_23 AC 101 ms
6,676 KB
testcase_24 AC 124 ms
6,676 KB
testcase_25 AC 10 ms
6,676 KB
testcase_26 AC 73 ms
6,676 KB
testcase_27 AC 146 ms
6,676 KB
testcase_28 AC 110 ms
6,676 KB
testcase_29 AC 47 ms
6,676 KB
testcase_30 AC 12 ms
6,676 KB
testcase_31 AC 123 ms
6,676 KB
testcase_32 AC 20 ms
6,676 KB
testcase_33 AC 114 ms
6,676 KB
testcase_34 AC 70 ms
6,676 KB
testcase_35 AC 137 ms
6,676 KB
testcase_36 AC 116 ms
6,676 KB
testcase_37 AC 161 ms
6,676 KB
testcase_38 AC 142 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int MOD=998244353;

namespace Lib{
  ll modpow(long long a,int n){
    long long ret=1,t=a;
    while(n>0){
      if(n&1)ret=ret*t%MOD;
      t=t*t%MOD;
      n/=2;
    }
    return ret;
  }
}

void solve();
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int test_case;
  cin>>test_case;
  while (test_case--){
    solve();
  }
}
ll modinv(ll n){
  return Lib::modpow(n,MOD-2);
}
void solve(){
  int N;
  cin>>N;
  vector A(N,array<int,2>());
  for(auto &i:A)cin>>i[0]>>i[1];
  ll p2=0,Rs=0,Is=0;
  for(auto i:A){
    p2=(p2+i[0]*i[0]+i[1]*i[1])%MOD;
    Rs=(Rs+(i[0]*i[0]-i[1]*i[1])*modinv(i[0]*i[0]+i[1]*i[1]))%MOD;
    Is=(Is+2*i[0]*i[1]*modinv(i[0]*i[0]+i[1]*i[1]))%MOD;
  }
  ll ans=0;
  for(auto i:A){
    ll b=i[0]*i[0]+i[1]*i[1];
    ll pr=(i[0]*i[0]-i[1]*i[1])*modinv(b)%MOD,pi=(-2*i[0]*i[1])*modinv(b)%MOD;

    ans=(ans+p2*modinv(b)*2)%MOD;
    ans=(ans-Rs*pr*2+Is*pi*2)%MOD;
  }
  ans=(ans+MOD)%MOD;
  ans=(ans*((MOD+1)/2))%MOD;
  cout<<ans<<'\n';
}
0