結果
問題 | No.1083 余りの余り |
ユーザー |
|
提出日時 | 2020-06-19 22:30:14 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 285 ms / 3,000 ms |
コード長 | 795 bytes |
コンパイル時間 | 12,676 ms |
コンパイル使用メモリ | 396,676 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-03 15:05:06 |
合計ジャッジ時間 | 15,599 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
ソースコード
use std::cmp::*;use std::io::*;fn main() {let mut s: String = String::new();std::io::stdin().read_to_string(&mut s).ok();let mut itr = s.trim().split_whitespace();let n: usize = itr.next().unwrap().parse().unwrap();let k: usize = itr.next().unwrap().parse().unwrap();let mut a: Vec<usize> = (0..n).map(|_| itr.next().unwrap().parse().unwrap()).collect();a.sort_by(|a, b| b.cmp(a));let mut ans = 0;for bit in 1..1 << n {let mut b = Vec::new();for i in 0..n {if bit >> i & 1 == 1 {b.push(a[i]);}}let mut tmp = k;for i in 0..b.len() {tmp %= b[i];}ans = max(ans, tmp % a[n - 1]);}println!("{}", ans);}