結果

問題 No.269 見栄っ張りの募金活動
コンテスト
ユーザー moricup
提出日時 2020-09-24 00:31:33
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 15 ms / 5,000 ms
コード長 1,544 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,146 ms
コンパイル使用メモリ 179,808 KB
実行使用メモリ 19,584 KB
最終ジャッジ日時 2026-03-16 15:59:20
合計ジャッジ時間 2,558 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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