結果
| 問題 |
No.641 Team Contest Estimation
|
| コンテスト | |
| ユーザー |
夕叢霧香(ゆうむらきりか)
|
| 提出日時 | 2018-01-16 00:51:03 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,871 bytes |
| コンパイル時間 | 3,206 ms |
| コンパイル使用メモリ | 77,664 KB |
| 実行使用メモリ | 50,496 KB |
| 最終ジャッジ日時 | 2024-12-25 21:06:40 |
| 合計ジャッジ時間 | 6,030 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | AC * 2 WA * 7 |
ソースコード
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;
}
}
}
夕叢霧香(ゆうむらきりか)