結果

問題 No.1011 Infinite Stairs
ユーザー ks2mks2m
提出日時 2020-03-20 21:59:26
言語 Java21
(openjdk 21)
結果
AC  
実行時間 733 ms / 2,000 ms
コード長 762 bytes
コンパイル時間 3,544 ms
コンパイル使用メモリ 73,496 KB
実行使用メモリ 339,596 KB
最終ジャッジ日時 2023-09-24 10:57:26
合計ジャッジ時間 7,296 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
47,336 KB
testcase_01 AC 43 ms
49,496 KB
testcase_02 AC 69 ms
53,940 KB
testcase_03 AC 495 ms
219,804 KB
testcase_04 AC 142 ms
76,576 KB
testcase_05 AC 733 ms
339,596 KB
testcase_06 AC 144 ms
47,388 KB
testcase_07 AC 70 ms
51,248 KB
testcase_08 AC 42 ms
49,428 KB
testcase_09 AC 42 ms
49,568 KB
testcase_10 AC 53 ms
49,884 KB
testcase_11 AC 159 ms
84,512 KB
testcase_12 AC 52 ms
51,332 KB
testcase_13 AC 121 ms
67,984 KB
testcase_14 AC 44 ms
49,836 KB
testcase_15 AC 137 ms
76,956 KB
testcase_16 AC 357 ms
177,252 KB
testcase_17 AC 97 ms
60,928 KB
testcase_18 AC 231 ms
114,284 KB
testcase_19 AC 55 ms
49,992 KB
testcase_20 AC 47 ms
50,156 KB
testcase_21 AC 134 ms
76,420 KB
testcase_22 AC 227 ms
111,312 KB
testcase_23 AC 164 ms
83,632 KB
testcase_24 AC 154 ms
83,728 KB
testcase_25 AC 217 ms
111,196 KB
testcase_26 AC 100 ms
61,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int d = Integer.parseInt(sa[1]);
		int k = Integer.parseInt(sa[2]) - n;
		br.close();

		int mod = 1000000007;
		long[][] dp = new long[n + 1][k + 1];
		dp[0][0] = 1;
		for (int i = 0; i < n; i++) {
			for (int j = 1; j <= k; j++) {
				dp[i][j] += dp[i][j - 1];
			}
			for (int j = 0; j <= k; j++) {
				dp[i + 1][j] += dp[i][j];
				if (j >= d) {
					dp[i + 1][j] -= dp[i][j - d];
				}
				dp[i + 1][j] %= mod;
			}
		}
		System.out.println(dp[n][k]);
	}
}
0