結果

問題 No.1011 Infinite Stairs
ユーザー tentententen
提出日時 2021-11-04 11:42:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 320 ms / 2,000 ms
コード長 1,640 bytes
コンパイル時間 3,089 ms
コンパイル使用メモリ 77,992 KB
実行使用メモリ 168,644 KB
最終ジャッジ日時 2024-04-22 09:56:42
合計ジャッジ時間 6,681 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
37,124 KB
testcase_01 AC 55 ms
36,768 KB
testcase_02 AC 85 ms
39,296 KB
testcase_03 AC 244 ms
117,092 KB
testcase_04 AC 106 ms
54,152 KB
testcase_05 AC 320 ms
168,644 KB
testcase_06 AC 57 ms
36,772 KB
testcase_07 AC 82 ms
38,296 KB
testcase_08 AC 56 ms
37,324 KB
testcase_09 AC 56 ms
37,108 KB
testcase_10 AC 67 ms
38,048 KB
testcase_11 AC 109 ms
54,200 KB
testcase_12 AC 67 ms
37,864 KB
testcase_13 AC 93 ms
49,836 KB
testcase_14 AC 59 ms
37,144 KB
testcase_15 AC 104 ms
54,164 KB
testcase_16 AC 191 ms
96,500 KB
testcase_17 AC 86 ms
45,744 KB
testcase_18 AC 148 ms
73,316 KB
testcase_19 AC 63 ms
37,520 KB
testcase_20 AC 54 ms
37,276 KB
testcase_21 AC 105 ms
53,944 KB
testcase_22 AC 131 ms
65,024 KB
testcase_23 AC 109 ms
54,012 KB
testcase_24 AC 111 ms
53,936 KB
testcase_25 AC 132 ms
64,768 KB
testcase_26 AC 85 ms
45,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int d = sc.nextInt();
        int k = sc.nextInt();
        int[][] dp = new int[n + 1][k + 1];
        Arrays.fill(dp[0], 1);
        for (int i = 1; i <= n; i++) {
            for (int j = i; j <= k; j++) {
                dp[i][j] = dp[i][j - 1];
                if (j > d) {
                    dp[i][j] += (dp[i - 1][j - 1] - dp[i - 1][j - d - 1] + MOD) % MOD;
                    dp[i][j] %= MOD;
                } else {
                    dp[i][j] += dp[i - 1][j - 1];
                    dp[i][j] %= MOD;
                }
            }
        }
        System.out.println((dp[n][k] - dp[n][k - 1] + MOD) % MOD);
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String nextLine() throws Exception {
        return br.readLine();
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0