結果
問題 | No.1083 余りの余り |
ユーザー |
|
提出日時 | 2022-12-20 22:53:51 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 51 ms / 3,000 ms |
コード長 | 677 bytes |
コンパイル時間 | 10,312 ms |
コンパイル使用メモリ | 380,884 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-18 02:09:15 |
合計ジャッジ時間 | 11,853 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
ソースコード
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 mut a: Vec<usize> = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();a.sort();a.reverse();let minval = a.pop().unwrap();let mut result = k % minval;let n = n-1;for i in 1..1usize<<n {result = result.max((0..n).filter(|&j| ((i >> j) & 1) == 1).fold(k, |x, y| x % a[y]) % minval);}println!("{}", result);}