結果
| 問題 |
No.269 見栄っ張りの募金活動
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-07-05 20:41:10 |
| 言語 | Java (openjdk 23) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,929 bytes |
| コンパイル時間 | 2,248 ms |
| コンパイル使用メモリ | 80,612 KB |
| 実行使用メモリ | 60,304 KB |
| 最終ジャッジ日時 | 2024-07-01 02:40:56 |
| 合計ジャッジ時間 | 4,766 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 RE * 4 |
ソースコード
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();
}
}
}