結果

問題 No.269 見栄っ張りの募金活動
ユーザー takeya_okinotakeya_okino
提出日時 2017-07-04 21:35:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 199 ms / 5,000 ms
コード長 760 bytes
コンパイル時間 1,992 ms
コンパイル使用メモリ 73,632 KB
実行使用メモリ 69,020 KB
最終ジャッジ日時 2023-09-23 01:23:56
合計ジャッジ時間 6,885 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,892 KB
testcase_01 AC 124 ms
56,040 KB
testcase_02 AC 129 ms
56,256 KB
testcase_03 AC 141 ms
57,676 KB
testcase_04 AC 160 ms
60,604 KB
testcase_05 AC 126 ms
56,064 KB
testcase_06 AC 124 ms
56,096 KB
testcase_07 AC 199 ms
69,020 KB
testcase_08 AC 125 ms
55,868 KB
testcase_09 AC 162 ms
64,392 KB
testcase_10 AC 121 ms
55,684 KB
testcase_11 AC 140 ms
58,244 KB
testcase_12 AC 155 ms
60,128 KB
testcase_13 AC 140 ms
58,412 KB
testcase_14 AC 125 ms
55,632 KB
testcase_15 AC 139 ms
57,912 KB
testcase_16 AC 153 ms
60,184 KB
testcase_17 AC 138 ms
56,020 KB
testcase_18 AC 178 ms
64,508 KB
testcase_19 AC 144 ms
57,784 KB
testcase_20 AC 130 ms
55,512 KB
testcase_21 AC 129 ms
55,440 KB
testcase_22 AC 140 ms
57,872 KB
testcase_23 AC 129 ms
55,584 KB
testcase_24 AC 134 ms
55,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    long MOD = (long)Math.pow(10, 9) + 7;
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int S = sc.nextInt();
    int K = sc.nextInt();
    // dp[i][j]はi人募金した時点で確定金額がj円となる場合の数
    long[][] dp = new long[N + 1][S + 1];
    for(int i = 0; i <= S; i++) {
      if(N * i < S + 1) dp[1][N * i] = 1;
    }
    for(int i = 2; i < N + 1; i++) {
      for(int j = 0; j < S + 1; j++) {
        if(j >= K * (N - i + 1)) dp[i][j] = (dp[i][j] + dp[i - 1][j - K * (N - i + 1)]) % MOD;
        if(j >= (N - i + 1)) dp[i][j] = (dp[i][j] + dp[i][j - (N - i + 1)]) % MOD;
      }
    }
    System.out.println(dp[N][S]);
  }
}
0