結果

問題 No.269 見栄っ張りの募金活動
ユーザー motimoti
提出日時 2015-08-28 03:27:17
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,087 ms / 5,000 ms
コード長 933 bytes
コンパイル時間 622 ms
コンパイル使用メモリ 88,544 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-23 01:12:17
合計ジャッジ時間 5,054 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 5 ms
4,376 KB
testcase_04 AC 762 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 1,087 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 325 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 143 ms
4,376 KB
testcase_14 AC 97 ms
4,380 KB
testcase_15 AC 206 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 218 ms
4,376 KB
testcase_19 AC 70 ms
4,376 KB
testcase_20 AC 46 ms
4,376 KB
testcase_21 AC 155 ms
4,376 KB
testcase_22 AC 51 ms
4,376 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 124 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)

int const MOD = 1e9+7;

typedef long long ll;

int dp[2][20001];

int main() {

  int N, S, K; cin >> N >> S >> K;
  S -= N*(N-1)/2*K;
  if(S < 0) { cout << 0 << endl; return 0; }
  dp[0][S] = 1;
  for(int i=0; i<N; i++) {
    rep(j, 20001) dp[(i+1)&1][j] = 0;
    rep(j, S+1) {
      int* cur = &dp[i&1][j];
      if(!*cur) { continue; }
      rep(k, j/(N-i)+1) {
        int* tar = &dp[(i+1)&1][j-k*(N-i)];
        *tar += *cur;
        if(*tar >= MOD) {
          *tar -= MOD;
        }
      }
    }
  }

  cout << dp[N&1][0] << endl;

  return 0;
}
0