結果

問題 No.269 見栄っ張りの募金活動
ユーザー GrenacheGrenache
提出日時 2015-08-22 00:06:16
言語 Java
(openjdk 23)
結果
AC  
実行時間 141 ms / 5,000 ms
コード長 934 bytes
コンパイル時間 4,546 ms
コンパイル使用メモリ 77,636 KB
実行使用メモリ 63,416 KB
最終ジャッジ日時 2024-07-16 01:31:25
合計ジャッジ時間 6,995 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder269 {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        final int MOD = 1_000_000_007;
        int n = sc.nextInt();
        int s = sc.nextInt();
        int k = sc.nextInt();

        if (s < k * n * (n - 1) / 2) {
        	System.out.println("0");
        } else {
        	int m = s - k * n * (n - 1) / 2;
        	int[][] dp = new int[n + 1][m + 1];
        	dp[0][0] = 1;
        	for (int i = 1; i <= n; i++) {
        		for (int j = 0; j <= m; j++) {
        			if (j - i >= 0) {
        				dp[i][j] = (dp[i][j - i] + dp[i - 1][j]) % MOD;
        			} else {
        				dp[i][j] = dp[i - 1][j];
        			}
        		}
        	}

        	int ret = 0;
//        	for (int i = 1; i <= n; i++) {
        		ret = (ret + dp[n][m]) % MOD;
//        	}
        	System.out.println(ret);
        }

        sc.close();
    }
}
0