結果
問題 | No.269 見栄っ張りの募金活動 |
ユーザー |
![]() |
提出日時 | 2015-08-28 03:31:14 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1,028 ms / 5,000 ms |
コード長 | 962 bytes |
コンパイル時間 | 805 ms |
コンパイル使用メモリ | 88,632 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-16 01:49:36 |
合計ジャッジ時間 | 4,544 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#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 main() { int N, S, K; cin >> N >> S >> K; S -= N*(N-1)/2*K; if(S < 0) { cout << 0 << endl; return 0; } int dp[2][20001]; rep(j, 20001) dp[0][j] = 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; }