結果
| 問題 | 
                            No.269 見栄っ張りの募金活動
                             | 
                    
| コンテスト | |
| ユーザー | 
                             sugarrr
                         | 
                    
| 提出日時 | 2018-03-10 11:49:41 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 19 ms / 5,000 ms | 
| コード長 | 975 bytes | 
| コンパイル時間 | 847 ms | 
| コンパイル使用メモリ | 79,916 KB | 
| 実行使用メモリ | 19,072 KB | 
| 最終ジャッジ日時 | 2024-07-16 02:03:06 | 
| 合計ジャッジ時間 | 1,430 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 22 | 
ソースコード
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>
using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/
#define rep(i,l,r) for(int i=l;i<=r;i++)
const double EPS=1E-8;
////////////////////////////////////////
int main() {
    int n,s,k;cin>>n>>s>>k;
    s-=k*(n-1)*n/2;
    if(s<0){
        cout<<0<<endl;return 0;
    }
    //sをn個に分ける
    ll dp[n+1][s+1];memset(dp,0,sizeof(dp));dp[0][0]=1;
    rep(i,1,n){
        rep(j,0,s){
            if(j-(n-i+1)>=0)dp[i][j]=mod(dp[i-1][j]+dp[i][j-(n-i+1)]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][s];
    return 0;
}
            
            
            
        
            
sugarrr