結果
問題 | No.2651 [Cherry 6th Tune B] $\mathbb{C}$omplex комбинат |
ユーザー | LyricalMaestro |
提出日時 | 2024-12-15 02:03:47 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,190 ms / 2,500 ms |
コード長 | 2,359 bytes |
コンパイル時間 | 509 ms |
コンパイル使用メモリ | 82,256 KB |
実行使用メモリ | 147,828 KB |
最終ジャッジ日時 | 2024-12-15 02:04:59 |
合計ジャッジ時間 | 69,376 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 37 ms
52,736 KB |
testcase_01 | AC | 37 ms
51,968 KB |
testcase_02 | AC | 2,105 ms
78,276 KB |
testcase_03 | AC | 2,065 ms
81,448 KB |
testcase_04 | AC | 2,101 ms
82,084 KB |
testcase_05 | AC | 2,103 ms
103,856 KB |
testcase_06 | AC | 2,078 ms
104,252 KB |
testcase_07 | AC | 2,091 ms
95,336 KB |
testcase_08 | AC | 2,099 ms
103,656 KB |
testcase_09 | AC | 2,077 ms
106,800 KB |
testcase_10 | AC | 2,112 ms
123,276 KB |
testcase_11 | AC | 2,103 ms
105,284 KB |
testcase_12 | AC | 2,083 ms
117,760 KB |
testcase_13 | AC | 2,118 ms
125,956 KB |
testcase_14 | AC | 2,118 ms
115,756 KB |
testcase_15 | AC | 2,098 ms
108,516 KB |
testcase_16 | AC | 2,125 ms
125,364 KB |
testcase_17 | AC | 2,110 ms
119,548 KB |
testcase_18 | AC | 2,097 ms
130,856 KB |
testcase_19 | AC | 2,116 ms
134,128 KB |
testcase_20 | AC | 2,190 ms
80,456 KB |
testcase_21 | AC | 717 ms
96,472 KB |
testcase_22 | AC | 1,178 ms
114,908 KB |
testcase_23 | AC | 1,463 ms
114,576 KB |
testcase_24 | AC | 1,776 ms
140,636 KB |
testcase_25 | AC | 210 ms
79,488 KB |
testcase_26 | AC | 1,065 ms
106,848 KB |
testcase_27 | AC | 2,115 ms
147,828 KB |
testcase_28 | AC | 1,575 ms
132,216 KB |
testcase_29 | AC | 741 ms
99,292 KB |
testcase_30 | AC | 235 ms
80,452 KB |
testcase_31 | AC | 1,763 ms
141,028 KB |
testcase_32 | AC | 350 ms
83,840 KB |
testcase_33 | AC | 1,616 ms
132,196 KB |
testcase_34 | AC | 1,025 ms
106,080 KB |
testcase_35 | AC | 1,897 ms
133,516 KB |
testcase_36 | AC | 1,598 ms
84,276 KB |
testcase_37 | AC | 2,110 ms
139,080 KB |
testcase_38 | AC | 2,086 ms
139,420 KB |
ソースコード
## https://yukicoder.me/problems/no/2651 MOD = 998244353 def solve(N, xy): z2_list = [] for x, y in xy: x_ = (pow(x, 2, MOD) - pow(y, 2, MOD)) % MOD y_ = (x * y) % MOD y_ *= 2 y_ %= MOD z2_list.append((x_, y_)) z_abs_list = [] for x, y in xy: s = pow(x, 2, MOD) s += pow(y, 2, MOD) s %= MOD z_abs_list.append(s) # 1 / |z|^2 の累積和計算 cum_inv_z_abs2_list = [0] * N cum_inv_z_abs2 = 0 for i in range(N): cum_inv_z_abs2_list[i] = cum_inv_z_abs2 cum_inv_z_abs2 += pow(z_abs_list[i], (MOD - 2), MOD) cum_inv_z_abs2 %= MOD # |z|^2 の累積和計算 cum_z_abs2_list = [0] * N cum_z_abs2 = 0 for i in range(N): cum_z_abs2_list[i] = cum_z_abs2 cum_z_abs2 += z_abs_list[i] cum_z_abs2 %= MOD # cum_a_list = cum_a_list = [0] * N cum_a = 0 for i in range(N): cum_a_list[i] = cum_a a = z2_list[i][0] a *= pow(z_abs_list[i], MOD - 2, MOD) a %= MOD cum_a += a cum_a %= MOD cum_b_list = [0] * N cum_b = 0 for i in range(N): cum_b_list[i] = cum_b a = z2_list[i][1] a *= pow(z_abs_list[i], MOD - 2, MOD) a %= MOD cum_b += a cum_b %= MOD answer = 0 for i in range(N): ans = (z_abs_list[i] * cum_inv_z_abs2_list[i]) % MOD ans += (cum_z_abs2_list[i] * pow(z_abs_list[i], MOD - 2, MOD)) % MOD ans %= MOD ans_re1 = (z2_list[i][0] * pow(z_abs_list[i], MOD - 2, MOD)) % MOD ans_re1 *= cum_a_list[i] ans_re1 %= MOD ans_re2 = (z2_list[i][1] * pow(z_abs_list[i], MOD - 2, MOD)) % MOD ans_re2 *= cum_b_list[i] ans_re2 %= MOD ans_re = (ans_re1 + ans_re2) % MOD ans_re *= -2 ans_re %= MOD answer += ans answer %= MOD answer += ans_re answer %= MOD return answer def main(): T = int(input()) answers = [] for _ in range(T): N = int(input()) xy = [] for _ in range(N): x, y = map(int, input().split()) xy.append((x, y)) ans = solve(N, xy) answers.append(ans) for ans in answers: print(ans) if __name__ == "__main__": main()