結果

問題 No.1463 Hungry Kanten
ユーザー phsplsphspls
提出日時 2022-11-05 23:56:30
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 858 bytes
コンパイル時間 1,574 ms
コンパイル使用メモリ 154,724 KB
実行使用メモリ 15,028 KB
最終ジャッジ日時 2023-09-26 23:08:14
合計ジャッジ時間 3,792 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 68 ms
15,028 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 4 ms
4,376 KB
testcase_17 AC 10 ms
4,380 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 36 ms
8,432 KB
testcase_20 AC 42 ms
8,444 KB
testcase_21 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::collections::HashSet;


fn main() {
    let mut nk = String::new();
    std::io::stdin().read_line(&mut nk).ok();
    let nk: Vec<usize> = nk.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = nk[0];
    let k = nk[1];
    let mut a = String::new();
    std::io::stdin().read_line(&mut a).ok();
    let a: Vec<usize> = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    
    let mut result = HashSet::new();
    for i in 1..1usize<<n {
        if (i.count_ones() as usize) < k { continue; }
        let addval = (0..n).filter(|&j| ((i >> j) & 1) == 1).map(|j| a[j]).sum::<usize>();
        let mulval = (0..n).filter(|&j| ((i >> j) & 1) == 1).map(|j| a[j] as u128).fold(1u128, |x, y| x * y);
        result.insert(addval as u128);
        result.insert(mulval);
    }
    println!("{}", result.len());
}
0