結果

問題 No.269 見栄っ張りの募金活動
ユーザー moricupmoricup
提出日時 2020-09-24 00:31:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 5,000 ms
コード長 1,544 bytes
コンパイル時間 1,416 ms
コンパイル使用メモリ 164,644 KB
実行使用メモリ 19,432 KB
最終ジャッジ日時 2023-09-10 13:14:45
合計ジャッジ時間 3,129 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
19,200 KB
testcase_01 AC 17 ms
19,120 KB
testcase_02 AC 17 ms
19,108 KB
testcase_03 AC 17 ms
19,144 KB
testcase_04 AC 18 ms
19,248 KB
testcase_05 AC 17 ms
19,340 KB
testcase_06 AC 18 ms
19,236 KB
testcase_07 AC 18 ms
19,200 KB
testcase_08 AC 17 ms
19,304 KB
testcase_09 AC 18 ms
19,156 KB
testcase_10 AC 18 ms
19,344 KB
testcase_11 AC 17 ms
19,184 KB
testcase_12 AC 18 ms
19,132 KB
testcase_13 AC 18 ms
19,340 KB
testcase_14 AC 18 ms
19,244 KB
testcase_15 AC 18 ms
19,196 KB
testcase_16 AC 17 ms
19,196 KB
testcase_17 AC 17 ms
19,424 KB
testcase_18 AC 18 ms
19,432 KB
testcase_19 AC 17 ms
19,160 KB
testcase_20 AC 18 ms
19,304 KB
testcase_21 AC 18 ms
19,180 KB
testcase_22 AC 18 ms
19,244 KB
testcase_23 AC 18 ms
19,168 KB
testcase_24 AC 18 ms
19,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

//typedef
typedef unsigned int UINT;
typedef unsigned long long ULL;
typedef long long LL;
typedef pair<long long, long long> PLL;
typedef tuple<long long, long long, long long> TLL3;
typedef tuple<long long, long long, long long, long long> TLL4;
typedef set<LL, greater<LL> > setdownLL;
#define PQ priority_queue
typedef PQ<LL, vector<LL>, greater<LL> > pqupLL;
//container utill
#define ALL(v) (v).begin(),(v).end()
#define CR [](auto element1, auto element2){return element1>element2;}
#define LB lower_bound
#define UP upper_bound
#define PB push_back
#define MP make_pair
#define MT make_tuple
//constant
#define PI 3.141592653589793

const long long MOD = 1000000007;

const long long N_MAX = 20001;
const long long K_MAX = 101;

long long part[N_MAX][K_MAX];

void part_int(){
    long long n,k;
    for(k=1; k<K_MAX; k++){
        part[0][k]=1;
    }
    for(n=0; n<N_MAX; n++){
        part[n][1]=1;
    }
    for(n=1; n<N_MAX; n++){
        for(k=2; k<K_MAX; k++){
            if(n-k<0){
                part[n][k]=part[n][k-1];
            }else{
                part[n][k]=part[n][k-1]+part[n-k][k];
                part[n][k]%=MOD;
            }
        }
    }
}

int main(){
    part_int();

    //input
    LL N,S,K;
    cin >> N >> S >> K;

    //calc
    LL miekiller=0;
    LL i;
    for(i=0; i<N; i++){
        miekiller+=(i*K);
    }

    //output
    if(S-miekiller<0){
        cout << 0 << endl;
    }else{
        cout << part[S-miekiller][N] << endl;
    }
    return 0;
}
0