結果
問題 |
No.269 見栄っ張りの募金活動
|
ユーザー |
![]() |
提出日時 | 2015-08-22 01:05:28 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 5 ms / 5,000 ms |
コード長 | 650 bytes |
コンパイル時間 | 1,400 ms |
コンパイル使用メモリ | 159,928 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-16 01:31:27 |
合計ジャッジ時間 | 2,211 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ int N,S,K; cin >> N >> S >> K; S -= K*N*(N-1)/2; if( S < 0 ) cout << 0 << endl; else{ register int dp[2][20001]; dp[0][S] = 1; register int cur = 0; for(register int x = N ; x >= 1 ; x--){ for(register int j = 0 ; j <= S ; j++) dp[cur^1][j] = 0; for(register int s = S ; s >= 0 ; s--){ dp[cur^1][s] += dp[cur][s]; if( dp[cur^1][s] >= 1000000007 ) dp[cur^1][s] -= 1000000007; if( s - x >= 0 ){ dp[cur][s-x] += dp[cur][s]; if( dp[cur][s-x] >= 1000000007 ) dp[cur][s-x] -= 1000000007; } } cur ^= 1; } cout << dp[cur][0] << endl; } }