結果

問題 No.641 Team Contest Estimation
ユーザー 夕叢霧香(ゆうむらきりか)夕叢霧香(ゆうむらきりか)
提出日時 2018-01-16 00:51:03
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,871 bytes
コンパイル時間 2,474 ms
コンパイル使用メモリ 74,604 KB
実行使用メモリ 61,088 KB
最終ジャッジ日時 2023-08-26 19:34:09
合計ジャッジ時間 4,596 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 42 ms
49,424 KB
testcase_03 AC 43 ms
49,340 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
権限があれば一括ダウンロードができます

ソースコード

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[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