結果

問題 No.269 見栄っ張りの募金活動
ユーザー Goi_dudeGoi_dude
提出日時 2020-03-07 14:25:57
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 34 ms / 5,000 ms
コード長 1,071 bytes
コンパイル時間 2,044 ms
コンパイル使用メモリ 159,828 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-04-22 14:38:01
合計ジャッジ時間 3,136 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 14 ms
7,424 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 34 ms
12,416 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 5 ms
6,944 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 6 ms
6,940 KB
testcase_14 AC 3 ms
6,944 KB
testcase_15 AC 6 ms
6,940 KB
testcase_16 AC 1 ms
6,944 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 13 ms
6,940 KB
testcase_19 AC 5 ms
6,944 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 3 ms
6,940 KB
testcase_22 AC 4 ms
6,944 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 3 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int ans;
int n,s,k;

int a[101][20001];

int f(int n,int s){
    // k = 0  のときn人でちょうどs円払う方法
    if(a[n][s])return a[n][s];
    if(n==0)return !s;
    return a[n][s] = (f(n-1,s) + (s<n?0:f(n,s-n)))%mod;
}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cin >> n >> s >> k;
    s -= k*((n-1)*n)/2;
    if(s<0){
        cout << 0 << endl;
        return 0;
    }else{
        //cout << s << endl;
        cout << f(n,s) << endl;
    }
}
0