結果

問題 No.1011 Infinite Stairs
ユーザー phsplsphspls
提出日時 2022-11-24 11:11:38
言語 Rust
(1.77.0)
結果
AC  
実行時間 232 ms / 2,000 ms
コード長 873 bytes
コンパイル時間 1,642 ms
コンパイル使用メモリ 171,684 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-26 02:35:32
合計ジャッジ時間 5,009 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,372 KB
testcase_02 AC 4 ms
4,372 KB
testcase_03 AC 131 ms
4,372 KB
testcase_04 AC 232 ms
4,372 KB
testcase_05 AC 232 ms
4,372 KB
testcase_06 AC 1 ms
4,372 KB
testcase_07 AC 18 ms
4,372 KB
testcase_08 AC 1 ms
4,372 KB
testcase_09 AC 1 ms
4,372 KB
testcase_10 AC 5 ms
4,372 KB
testcase_11 AC 78 ms
4,372 KB
testcase_12 AC 2 ms
4,372 KB
testcase_13 AC 47 ms
4,372 KB
testcase_14 AC 3 ms
4,372 KB
testcase_15 AC 20 ms
4,372 KB
testcase_16 AC 159 ms
4,372 KB
testcase_17 AC 149 ms
4,372 KB
testcase_18 AC 54 ms
4,372 KB
testcase_19 AC 1 ms
4,372 KB
testcase_20 AC 4 ms
4,372 KB
testcase_21 AC 29 ms
4,372 KB
testcase_22 AC 143 ms
4,372 KB
testcase_23 AC 32 ms
4,372 KB
testcase_24 AC 24 ms
4,372 KB
testcase_25 AC 52 ms
4,372 KB
testcase_26 AC 12 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

const MOD: usize = 1e9 as usize + 7;

fn main() {
    let mut ndk = String::new();
    std::io::stdin().read_line(&mut ndk).ok();
    let ndk: Vec<usize> = ndk.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = ndk[0];
    let d = ndk[1];
    let k = ndk[2];

    let mut dp = vec![0usize];
    dp[0] = 1;
    for i in 0..n {
        let start = i+1;
        let end = (i+1) * d;
        let mut next_dp = vec![0usize; end-start+1];
        for j in 0..dp.len() {
            next_dp[j] += dp[j];
            next_dp[j] %= MOD;
            if next_dp.len() > j+d {
                next_dp[j+d] += MOD - dp[j];
                next_dp[j+d] %= MOD;
            }
        }
        for j in 1..next_dp.len() {
            next_dp[j] += next_dp[j-1];
            next_dp[j] %= MOD;
        }
        dp = next_dp;
    }
    println!("{}", dp[k-n]);
}
0