結果
| 問題 | No.542 1円玉と5円玉 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-02-21 21:06:11 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 786 bytes |
| コンパイル時間 | 14,626 ms |
| コンパイル使用メモリ | 378,732 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-08 20:08:02 |
| 合計ジャッジ時間 | 12,486 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
fn main() {
let mut ab = String::new();
std::io::stdin().read_line(&mut ab).ok();
let ab: Vec<usize> = ab.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
let a = ab[0];
let b = ab[1];
let mut dp: Vec<Vec<bool>> = vec![vec![false; 601]; a+b+1];
dp[0][0] = true;
for i in 0..a {
for j in 0..601 {
dp[i+1][j] |= dp[i][j];
if j >= 1 {
dp[i+1][j] |= dp[i][j-1];
}
}
}
for i in a..a+b {
for j in 0..601 {
dp[i+1][j] |= dp[i][j];
if j >= 5 {
dp[i+1][j] |= dp[i][j-5];
}
}
}
dp[a+b].iter().enumerate().skip(1).filter(|pair| *pair.1).for_each(|pair| {
println!("{}", pair.0);
});
}