結果

問題 No.269 見栄っ張りの募金活動
ユーザー eityanseityans
提出日時 2019-06-04 07:37:25
言語 Java
(openjdk 23)
結果
AC  
実行時間 139 ms / 5,000 ms
コード長 1,192 bytes
コンパイル時間 2,009 ms
コンパイル使用メモリ 79,360 KB
実行使用メモリ 63,168 KB
最終ジャッジ日時 2024-09-17 20:41:38
合計ジャッジ時間 5,817 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
 
 
public class Main {


	public static void main(String[] args) {
		// TODO Auto-generated method stub
		//int Q = Integer.parseInt(sc.next());
		//long L = Long.parseLong(sc.next());
		//char[] c = sc.next().toCharArray();
		int INF = Integer.MAX_VALUE;
		Scanner sc = new Scanner(System.in);
		
		int N = Integer.parseInt(sc.next());
		int S = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		int MOD = 1_000_000_007;
		
		int M = S - N*(N-1)*K/2;
		if(M<0){	//見栄張りすぎ
			System.out.println("0");
			return;
		}
		
		//MのN分割を求める
		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]%MOD;
				}
				
			}
		}
		
		System.out.println(dp[N][M]);
	}
}

0