結果

問題 No.269 見栄っ張りの募金活動
ユーザー Rayphobia12Rayphobia12
提出日時 2021-04-22 00:47:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 734 bytes
コンパイル時間 1,407 ms
コンパイル使用メモリ 164,372 KB
実行使用メモリ 159,932 KB
最終ジャッジ日時 2023-09-17 09:44:56
合計ジャッジ時間 8,864 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 RE -
testcase_04 RE -
testcase_05 WA -
testcase_06 WA -
testcase_07 RE -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 RE -
testcase_12 WA -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 WA -
testcase_17 WA -
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;
    cout << n << endl;
    memset(dp, -1, sizeof(dp));    
    if (n>=0) cout << PF(n, N)<< endl;    
  	else cout << "0" << endl;
}
0