結果
問題 | No.1083 余りの余り |
ユーザー |
![]() |
提出日時 | 2020-06-19 23:18:56 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 932 bytes |
コンパイル時間 | 13,820 ms |
コンパイル使用メモリ | 390,036 KB |
実行使用メモリ | 10,112 KB |
最終ジャッジ日時 | 2024-07-03 15:40:09 |
合計ジャッジ時間 | 16,199 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 WA * 4 |
ソースコード
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 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() }; let mut dp = vec![0; 1 << n]; dp[0] = k; for s in 0..(1 << n) { for i in 0..n { if (s & (1 << i)) != 0 { continue; } dp[s | (1 << i)] = { std::cmp::max( dp[s | (1 << i)], dp[s] % a[i], ) } } } let ans = dp[(1 << n) - 1]; println!("{}", ans); }