結果
| 問題 |
No.398 ハーフパイプ(2)
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2024-11-16 03:11:39 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 818 ms / 2,000 ms |
| コード長 | 1,416 bytes |
| コンパイル時間 | 11,451 ms |
| コンパイル使用メモリ | 385,320 KB |
| 実行使用メモリ | 101,632 KB |
| 最終ジャッジ日時 | 2024-11-16 03:12:12 |
| 合計ジャッジ時間 | 26,618 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
ソースコード
use std::io;
fn main() {
// 標準入力を受け取る
let mut input = String::new();
io::stdin().read_line(&mut input).unwrap();
let x: i32 = (input.trim().parse::<f64>().unwrap() * 4.0) as i32;
// DP配列の初期化
let mut dp = vec![vec![vec![0i64; 101]; 101]; 601];
dp[0][100][0] = 1;
// 6回のステップを繰り返す
for _ in 0..6 {
let mut ndp = vec![vec![vec![0i64; 101]; 101]; 601];
for sum in 0..601 {
for min in 0..101 {
for max in 0..101 {
if dp[sum][min][max] == 0 {
continue;
}
for i in 0..101 {
let min2 = std::cmp::min(min, i);
let max2 = std::cmp::max(max, i);
let sum2 = sum + i;
if sum2 < 601 {
ndp[sum2][min2][max2] += dp[sum][min][max];
}
}
}
}
}
dp = ndp;
}
// 答えを計算する
let mut ans = 0;
for sum in 0..601 {
for min in 0..101 {
for max in 0..101 {
if sum as i32 - min as i32 - max as i32 == x {
ans += dp[sum][min][max];
}
}
}
}
// 結果を出力
println!("{}", ans);
}
titia