結果

問題 No.641 Team Contest Estimation
ユーザー koba-e964koba-e964
提出日時 2021-11-01 13:14:45
言語 Rust
(1.77.0)
結果
TLE  
実行時間 -
コード長 1,649 bytes
コンパイル時間 752 ms
コンパイル使用メモリ 172,976 KB
実行使用メモリ 13,880 KB
最終ジャッジ日時 2024-04-18 08:14:15
合計ジャッジ時間 4,470 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes.by_ref().map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr,) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

const MOD: i64 = 1_000_000_009;

fn main() {
    input! {
        n: usize, k: usize,
        a: [i64; n],
    }
    let mut c = vec![0i32; k];
    for i in 0..k {
        let mut tmp = 0;
        for &a in &a {
            if (a & 1 << i) != 0 {
                tmp += 1;
            }
        }
        c[i] = tmp;
    }
    let mut tmp = (1i64 << k) - 1;
    tmp %= MOD;
    tmp *= (1 << (k - 1)) % MOD;
    tmp %= MOD;
    println!("{}", tmp * n as i64 % MOD);
    let mut ans = 0;
    for i in (0..k).rev() {
        let x = 2 * c[i] as i64 - n as i64;
        let x = x * x;
        ans = (4 * ans + x) % MOD;
    }
    for _ in 0..k - 1 {
        ans = 4 * ans % MOD;
    }
    println!("{}", ans);
}
0