結果

問題 No.1958 Bit Game
ユーザー tentententen
提出日時 2023-06-30 09:05:15
言語 Java21
(openjdk 21)
結果
AC  
実行時間 881 ms / 2,000 ms
コード長 2,864 bytes
コンパイル時間 4,165 ms
コンパイル使用メモリ 79,692 KB
実行使用メモリ 67,268 KB
最終ジャッジ日時 2023-09-21 03:24:38
合計ジャッジ時間 29,187 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 824 ms
67,084 KB
testcase_01 AC 826 ms
67,168 KB
testcase_02 AC 875 ms
66,800 KB
testcase_03 AC 852 ms
67,268 KB
testcase_04 AC 872 ms
66,428 KB
testcase_05 AC 865 ms
66,848 KB
testcase_06 AC 861 ms
67,260 KB
testcase_07 AC 853 ms
67,084 KB
testcase_08 AC 854 ms
66,900 KB
testcase_09 AC 881 ms
67,084 KB
testcase_10 AC 465 ms
59,108 KB
testcase_11 AC 565 ms
61,132 KB
testcase_12 AC 496 ms
63,300 KB
testcase_13 AC 680 ms
64,060 KB
testcase_14 AC 547 ms
60,324 KB
testcase_15 AC 542 ms
65,476 KB
testcase_16 AC 370 ms
61,616 KB
testcase_17 AC 764 ms
65,616 KB
testcase_18 AC 713 ms
65,120 KB
testcase_19 AC 516 ms
63,724 KB
testcase_20 AC 722 ms
60,084 KB
testcase_21 AC 564 ms
63,504 KB
testcase_22 AC 563 ms
60,312 KB
testcase_23 AC 498 ms
60,548 KB
testcase_24 AC 700 ms
66,064 KB
testcase_25 AC 478 ms
59,180 KB
testcase_26 AC 707 ms
61,292 KB
testcase_27 AC 488 ms
64,124 KB
testcase_28 AC 719 ms
63,008 KB
testcase_29 AC 476 ms
57,688 KB
testcase_30 AC 43 ms
49,228 KB
testcase_31 AC 43 ms
49,212 KB
testcase_32 AC 50 ms
49,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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();
    }
    
}
0