結果

問題 No.269 見栄っ張りの募金活動
ユーザー YazatenYazaten
提出日時 2018-07-04 15:32:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,769 ms / 5,000 ms
コード長 848 bytes
コンパイル時間 1,407 ms
コンパイル使用メモリ 164,580 KB
実行使用メモリ 19,384 KB
最終ジャッジ日時 2023-09-23 01:31:16
合計ジャッジ時間 12,241 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
19,328 KB
testcase_01 AC 7 ms
19,140 KB
testcase_02 AC 7 ms
19,116 KB
testcase_03 AC 13 ms
19,240 KB
testcase_04 AC 1,964 ms
19,124 KB
testcase_05 AC 7 ms
19,384 KB
testcase_06 AC 8 ms
19,092 KB
testcase_07 AC 2,769 ms
19,124 KB
testcase_08 AC 7 ms
19,112 KB
testcase_09 AC 7 ms
19,120 KB
testcase_10 AC 7 ms
19,096 KB
testcase_11 AC 956 ms
19,132 KB
testcase_12 AC 7 ms
19,116 KB
testcase_13 AC 408 ms
19,132 KB
testcase_14 AC 813 ms
19,172 KB
testcase_15 AC 581 ms
19,192 KB
testcase_16 AC 8 ms
19,116 KB
testcase_17 AC 7 ms
19,180 KB
testcase_18 AC 590 ms
19,192 KB
testcase_19 AC 194 ms
19,120 KB
testcase_20 AC 151 ms
19,120 KB
testcase_21 AC 689 ms
19,116 KB
testcase_22 AC 144 ms
19,140 KB
testcase_23 AC 10 ms
19,120 KB
testcase_24 AC 405 ms
19,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back

const ll MOD = 1e9+7;
signed main(){
    int n,s,k;
    cin>>n>>s>>k;
    
    s -= n*(n-1)/2*k;
    
    static int dp[101][20001];
    rep(i,101)rep(j,20001)dp[i][j] = 0;
    dp[0][0] = 1;
    
    for(int i=1;i<=n;i++){
        for(int j=0;j<=s;j++){
            int pay = 0;
            int remain = n-i+1;
            while(1){
                if(j-pay>=0){
                    dp[i][j] += dp[i-1][j-pay];
                    if(dp[i][j]>MOD)dp[i][j]-=MOD;
                }
                else break;
                pay += remain;
                int remain = n-i+1;
            }
        }
    }
    cout<<dp[n][s]<<endl;
}
0