結果
問題 | No.1083 余りの余り |
ユーザー |
![]() |
提出日時 | 2020-06-19 23:53:35 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 62 ms / 3,000 ms |
コード長 | 873 bytes |
コンパイル時間 | 17,744 ms |
コンパイル使用メモリ | 400,696 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-03 16:10:36 |
合計ジャッジ時間 | 15,932 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
ソースコード
fn main() { let (n, k): (usize, usize) = { let mut buf = String::new(); std::io::stdin().read_line(&mut buf).unwrap(); let mut iter = buf.split_whitespace(); ( iter.next().unwrap().parse().unwrap(), iter.next().unwrap().parse().unwrap(), ) }; let mut a: Vec<usize> = { let mut buf = String::new(); std::io::stdin().read_line(&mut buf).unwrap(); let iter = buf.split_whitespace(); iter.map(|x| x.parse().unwrap()).collect() }; a.sort_by(|a, b| b.cmp(a)); let mut ans = 0; for x in 0..(1 << (n - 1)) { let mut res = k; for i in 0..(n - 1) { if (x & (1 << i)) != 0 { res %= a[i]; } } res %= a[n - 1]; ans = std::cmp::max(ans, res); } println!("{}", ans); }