結果

問題 No.641 Team Contest Estimation
ユーザー 夕叢霧香(ゆうむらきりか)夕叢霧香(ゆうむらきりか)
提出日時 2018-01-19 23:17:33
言語 Java21
(openjdk 21)
結果
AC  
実行時間 253 ms / 2,000 ms
コード長 2,873 bytes
コンパイル時間 1,900 ms
コンパイル使用メモリ 74,508 KB
実行使用メモリ 60,592 KB
最終ジャッジ日時 2023-08-26 19:34:14
合計ジャッジ時間 3,941 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
49,424 KB
testcase_01 AC 39 ms
49,780 KB
testcase_02 AC 42 ms
49,568 KB
testcase_03 AC 41 ms
49,540 KB
testcase_04 AC 41 ms
49,700 KB
testcase_05 AC 249 ms
60,172 KB
testcase_06 AC 239 ms
60,540 KB
testcase_07 AC 253 ms
60,272 KB
testcase_08 AC 247 ms
60,592 KB
testcase_09 AC 40 ms
49,936 KB
testcase_10 AC 41 ms
49,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


class Main {
    static final long MOD=1000000009;
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n=sc.nextInt();
        int k=sc.nextInt();
        long[]a=new long[n];
        for(int i=0;i<n;++i)a[i]=sc.nextLong();
        long[]pow2=new long[200];
        pow2[0]=1;
        for(int i=1;i<pow2.length;++i)pow2[i]=pow2[i-1]*2%MOD;
        if(k==0){
            out.println(0);
            out.println(0);
            out.close();
            return;
        }
        out.println((n*(pow2[k]-1)%MOD)*pow2[k-1]%MOD);
        long v=0;
        for(int b=0;b<k;++b){
            int one=0;
            for(int i=0;i<n;++i){
                if((a[i]&1L<<b)!=0)one++;
            }
            long sig=(n*(MOD+1)/2+MOD-one)%MOD;
            sig=sig*sig%MOD;
            v+=sig*pow2[2*b]%MOD;
            v%=MOD;
        }
        // brute
        if(false){
            int sum=0;
            int sumsq=0;
            for(int i=0;i<1<<k;++i){
                int tot=0;
                for(int j=0;j<n;++j)tot+=i^a[j];
                sum+=tot;
                sumsq+=tot*tot;
            }
            System.err.println("sum="+sum);
            System.err.println("sumsq="+sumsq);
            System.err.println("sumsq-sum^2/(2^k)="+(sumsq-sum*sum/(1<<k)));
        }
        out.println(v*pow2[2*k]%MOD);
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        int[] nextIntArray(int n){
            int[]r=new int[n];
            for(int i=0;i<n;++i)r[i]=nextInt();
            return r;
        }
    }
}
0