結果

問題 No.269 見栄っ張りの募金活動
ユーザー Medo NasserMedo Nasser
提出日時 2018-07-05 20:41:10
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 1,929 bytes
コンパイル時間 2,107 ms
コンパイル使用メモリ 74,448 KB
実行使用メモリ 60,080 KB
最終ジャッジ日時 2023-09-13 18:01:49
合計ジャッジ時間 4,635 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,244 KB
testcase_01 AC 42 ms
49,356 KB
testcase_02 AC 43 ms
49,576 KB
testcase_03 AC 56 ms
51,528 KB
testcase_04 AC 79 ms
55,912 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 44 ms
49,460 KB
testcase_09 AC 56 ms
53,000 KB
testcase_10 AC 42 ms
49,464 KB
testcase_11 AC 59 ms
53,836 KB
testcase_12 AC 51 ms
51,672 KB
testcase_13 AC 62 ms
52,932 KB
testcase_14 RE -
testcase_15 AC 60 ms
53,840 KB
testcase_16 AC 50 ms
51,584 KB
testcase_17 AC 44 ms
49,616 KB
testcase_18 AC 77 ms
56,308 KB
testcase_19 AC 59 ms
52,344 KB
testcase_20 AC 56 ms
53,836 KB
testcase_21 AC 55 ms
54,920 KB
testcase_22 AC 58 ms
51,900 KB
testcase_23 AC 47 ms
49,616 KB
testcase_24 AC 56 ms
52,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main
{
	static final int mod = 1000*1000*1000 + 7;
	static int dp[][];
	static int n,s,k;
	public static int solve(int ind,int s) {
		//System.out.println(s);
		if (s < 0) {
			return 0;
		}
		if (ind == n) {
			return  s == 0 ? 1 : 0;
		}
		if (dp[ind][s] != -1) {
			return dp[ind][s];
		}
		int ret = 0;
		ret += solve(ind + 1,s);
		ret %= mod;
		ret += solve(ind,s - (n - ind));
		ret %= mod;
		return dp[ind][s] = ret;
	}
	public static void main(String[]args) throws Throwable {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();  s = sc.nextInt(); k = sc.nextInt();
		dp = new int[n][s];
		for (int i = 0 ; i < n ; ++i) {
			s -= i * k;
		}
		for (int i = 0 ; i < n ; ++i) {
			Arrays.fill(dp[i], -1);
		}
		System.out.println(solve(0,s));
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File(s)));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}
}
0