結果

問題 No.269 見栄っ張りの募金活動
ユーザー Rayphobia12Rayphobia12
提出日時 2021-04-22 00:47:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 711 bytes
コンパイル時間 2,909 ms
コンパイル使用メモリ 163,616 KB
実行使用メモリ 159,896 KB
最終ジャッジ日時 2023-09-17 09:45:14
合計ジャッジ時間 9,629 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
159,580 KB
testcase_01 AC 42 ms
159,896 KB
testcase_02 AC 42 ms
159,584 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 WA -
testcase_06 AC 42 ms
159,580 KB
testcase_07 RE -
testcase_08 AC 42 ms
159,708 KB
testcase_09 AC 41 ms
159,588 KB
testcase_10 AC 42 ms
159,864 KB
testcase_11 RE -
testcase_12 AC 42 ms
159,580 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 42 ms
159,640 KB
testcase_17 AC 42 ms
159,732 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;
long long 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);  
    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