結果
問題 | No.1958 Bit Game |
ユーザー | tenten |
提出日時 | 2023-06-30 09:05:15 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 828 ms / 2,000 ms |
コード長 | 2,864 bytes |
コンパイル時間 | 2,345 ms |
コンパイル使用メモリ | 95,732 KB |
実行使用メモリ | 57,300 KB |
最終ジャッジ日時 | 2024-07-06 22:03:19 |
合計ジャッジ時間 | 25,522 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 823 ms
56,940 KB |
testcase_01 | AC | 828 ms
57,100 KB |
testcase_02 | AC | 821 ms
57,164 KB |
testcase_03 | AC | 807 ms
57,024 KB |
testcase_04 | AC | 823 ms
56,708 KB |
testcase_05 | AC | 766 ms
56,948 KB |
testcase_06 | AC | 790 ms
57,300 KB |
testcase_07 | AC | 811 ms
57,012 KB |
testcase_08 | AC | 822 ms
57,128 KB |
testcase_09 | AC | 815 ms
57,048 KB |
testcase_10 | AC | 436 ms
47,636 KB |
testcase_11 | AC | 564 ms
50,324 KB |
testcase_12 | AC | 468 ms
51,656 KB |
testcase_13 | AC | 614 ms
52,336 KB |
testcase_14 | AC | 592 ms
48,824 KB |
testcase_15 | AC | 480 ms
55,204 KB |
testcase_16 | AC | 333 ms
49,040 KB |
testcase_17 | AC | 712 ms
55,148 KB |
testcase_18 | AC | 639 ms
55,164 KB |
testcase_19 | AC | 515 ms
52,800 KB |
testcase_20 | AC | 691 ms
50,144 KB |
testcase_21 | AC | 579 ms
54,860 KB |
testcase_22 | AC | 520 ms
49,952 KB |
testcase_23 | AC | 474 ms
49,360 KB |
testcase_24 | AC | 642 ms
53,476 KB |
testcase_25 | AC | 400 ms
47,404 KB |
testcase_26 | AC | 687 ms
52,020 KB |
testcase_27 | AC | 431 ms
54,300 KB |
testcase_28 | AC | 620 ms
52,596 KB |
testcase_29 | AC | 467 ms
49,540 KB |
testcase_30 | AC | 47 ms
37,240 KB |
testcase_31 | AC | 46 ms
37,032 KB |
testcase_32 | AC | 54 ms
36,572 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { static final int MOD = 998244353; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int a = sc.nextInt(); int b = sc.nextInt(); long[] valuesA = new long[a]; for (int i = 0; i < a; i++) { valuesA[i] = sc.nextLong(); } int[] countsA = new int[61]; for (int i = 0; i <= 60; i++) { for (long x : valuesA) { if ((x & (1L << i)) > 0) { countsA[i]++; } } } long[] valuesB = new long[b]; for (int i = 0; i < b; i++) { valuesB[i] = sc.nextLong(); } int[] countsB = new int[61]; for (int i = 0; i <= 60; i++) { for (long x : valuesB) { if ((x & (1L << i)) > 0) { countsB[i]++; } } } long ans = 0; for (int i = 0; i <= 60; i++) { long zero = 1; long one = 0; for (int j = 0; j < n; j++) { long zero1 = zero * (a - countsA[i]) % MOD; long one1 = ((zero + one) % MOD * countsA[i] % MOD + one * (a - countsA[i]) % MOD) % MOD; zero = ((zero1 + one1) % MOD * (b - countsB[i]) % MOD + zero1 * countsB[i] % MOD) % MOD; one = one1 * countsB[i] % MOD; } ans += (1L << i) % MOD * one % MOD; ans %= MOD; } System.out.println(ans); } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }