結果

問題 No.269 見栄っ張りの募金活動
ユーザー Rayphobia12Rayphobia12
提出日時 2021-04-22 00:39:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 699 bytes
コンパイル時間 1,562 ms
コンパイル使用メモリ 164,240 KB
実行使用メモリ 81,716 KB
最終ジャッジ日時 2023-09-17 09:44:23
合計ジャッジ時間 6,534 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
81,472 KB
testcase_01 AC 22 ms
81,676 KB
testcase_02 AC 22 ms
81,416 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 WA -
testcase_06 AC 22 ms
81,716 KB
testcase_07 RE -
testcase_08 AC 23 ms
81,420 KB
testcase_09 AC 22 ms
81,456 KB
testcase_10 AC 22 ms
81,468 KB
testcase_11 RE -
testcase_12 AC 22 ms
81,456 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 23 ms
81,456 KB
testcase_17 AC 23 ms
81,472 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 WA -
testcase_24 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
const int nn = 1000;
const int kk = 20000;
int dp[nn][kk];
using namespace std;
long long PF(int n, int k){    
    if (dp[n][k] != -1) return dp[n][k];
    int 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);  
    return dp[n][k] = res;
}
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