結果
問題 |
No.1958 Bit Game
|
ユーザー |
|
提出日時 | 2022-05-27 23:25:53 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 909 ms / 2,000 ms |
コード長 | 1,425 bytes |
コンパイル時間 | 1,538 ms |
コンパイル使用メモリ | 106,240 KB |
実行使用メモリ | 71,156 KB |
最終ジャッジ日時 | 2024-09-20 16:27:10 |
合計ジャッジ時間 | 20,727 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static void Main() { var c = NList; var (n, x, y) = (c[0], c[1], c[2]); var a = NList; var b = NList; WriteLine(Xor(n, x, y, a, b)); } static long Xor(int n, int x, int y, int[] a, int[] b) { var res = 0L; var mod = 998_244_353; for (var i = 0; i < 18; ++i) { var a1 = 0L; var b1 = 0L; foreach (var ai in a) a1 += (ai >> i) % 2; foreach (var bi in b) b1 += (bi >> i) % 2; var x_x = ((long)x * y - a1 * b1) % mod; var x_o = a1 * b1 % mod; var o_x = x * (y - b1) % mod; var o_o = x * b1 % mod; var dp = new long[n + 1][]; for (var j = 0; j < dp.Length; ++j) dp[j] = new long[2]; dp[0][0] = 1; for (var j = 0; j + 1 < dp.Length; ++j) { dp[j + 1][0] = (dp[j][0] * x_x % mod + dp[j][1] * o_x % mod) % mod; dp[j + 1][1] = (dp[j][0] * x_o % mod + dp[j][1] * o_o % mod) % mod; } res = (res + (dp[n][1] << i)) % mod; } return (res); } }