結果

問題 No.269 見栄っ張りの募金活動
ユーザー Rayphobia12Rayphobia12
提出日時 2021-04-22 01:16:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 746 bytes
コンパイル時間 1,554 ms
コンパイル使用メモリ 165,356 KB
実行使用メモリ 814,544 KB
最終ジャッジ日時 2023-09-17 09:47:00
合計ジャッジ時間 3,625 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
const int nn = 20001;
const int kk = 20001;
const long long mod = 1e9+7;
int dp[nn][kk];
using namespace std;

long long PF(int n, int k){    
    if (dp[n][k] != -1) return dp[n][k];
    long long res;

    // P(1,2)の様なケースが来たときは n==1のケースではなく、n-k<0のケース
    if (n-k<0) return res = PF(n, n);
    else if (n==1) return res = k;
    else if (n==0) return res = 1;
    else if (k==1) return res = 1;      	
    else res = (PF(n, k-1)+ PF(n-k, k))%mod;  
    return dp[n][k] = res%mod;
}
int main(){
    int N, S, K; cin >> N >> S >> K;   
    int n = S-N*(N-1)*K/2;
    memset(dp, -1, sizeof(dp));    
    if (n>=0) cout << PF(n, N)<< endl;    
  	else cout << "0" << endl;
}
0