結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,356 KB
testcase_01 AC 43 ms
49,308 KB
testcase_02 AC 45 ms
49,452 KB
testcase_03 AC 57 ms
51,380 KB
testcase_04 AC 78 ms
55,508 KB
testcase_05 AC 45 ms
49,476 KB
testcase_06 AC 44 ms
49,328 KB
testcase_07 AC 107 ms
62,400 KB
testcase_08 AC 44 ms
49,272 KB
testcase_09 AC 57 ms
52,884 KB
testcase_10 AC 44 ms
49,348 KB
testcase_11 AC 60 ms
53,524 KB
testcase_12 AC 57 ms
53,012 KB
testcase_13 AC 62 ms
52,324 KB
testcase_14 AC 56 ms
55,116 KB
testcase_15 AC 64 ms
52,880 KB
testcase_16 AC 57 ms
52,832 KB
testcase_17 AC 46 ms
49,476 KB
testcase_18 AC 82 ms
56,940 KB
testcase_19 AC 61 ms
52,484 KB
testcase_20 AC 56 ms
52,124 KB
testcase_21 AC 57 ms
53,672 KB
testcase_22 AC 58 ms
53,464 KB
testcase_23 AC 47 ms
49,628 KB
testcase_24 AC 58 ms
52,776 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 + 1];
		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