結果
問題 | No.1083 余りの余り |
ユーザー |
|
提出日時 | 2022-11-22 11:53:55 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 775 bytes |
コンパイル時間 | 12,952 ms |
コンパイル使用メモリ | 386,016 KB |
実行使用メモリ | 10,240 KB |
最終ジャッジ日時 | 2024-09-22 21:16:03 |
合計ジャッジ時間 | 15,730 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 WA * 1 |
ソースコード
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();let amins = a[0];let mut dp = vec![0usize; 1<<n];dp[0] = k;for i in 0..1<<n {for j in 0..n {if ((i >> j) & 1) == 1 { continue; }let idx = i | (1 << j);if dp[idx] % amins < dp[i] % a[j] % amins {dp[idx] = dp[i] % a[j];}}}println!("{}", dp[(1<<n)-1]);}