結果
問題 | No.1463 Hungry Kanten |
ユーザー |
|
提出日時 | 2022-11-05 23:56:30 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 858 bytes |
コンパイル時間 | 14,667 ms |
コンパイル使用メモリ | 388,064 KB |
実行使用メモリ | 15,024 KB |
最終ジャッジ日時 | 2024-07-19 16:55:21 |
合計ジャッジ時間 | 16,132 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 19 WA * 1 |
ソースコード
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());}