結果
問題 | No.641 Team Contest Estimation |
ユーザー |
![]() |
提出日時 | 2018-01-19 23:17:33 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 286 ms / 2,000 ms |
コード長 | 2,873 bytes |
コンパイル時間 | 2,088 ms |
コンパイル使用メモリ | 78,156 KB |
実行使用メモリ | 50,632 KB |
最終ジャッジ日時 | 2024-12-25 21:06:47 |
合計ジャッジ時間 | 4,280 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 9 |
ソースコード
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;}// bruteif(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;}}}