結果

問題 No.269 見栄っ張りの募金活動
ユーザー ctyl_0
提出日時 2015-10-06 01:34:02
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 23 ms / 5,000 ms
コード長 1,303 bytes
コンパイル時間 635 ms
コンパイル使用メモリ 87,484 KB
実行使用メモリ 19,328 KB
最終ジャッジ日時 2024-07-16 01:49:51
合計ジャッジ時間 1,426 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define var auto
#define mod 1000000007
typedef long long ll;
using namespace std;
int inputValue(){
int a;
cin >> a;
return a;
}
template <typename T>
void output(T a, int precision) {
if(precision > 0){
cout << setprecision(precision) << a << "\n";
}
else{
cout << a << "\n";
}
}
int main() {
// source code
int N = inputValue(); //
int S = inputValue(); //
int K = inputValue(); //
S -= K * N * (N - 1) / 2; //
if (S < 0) {
output(0, 0);
return 0;
}
vector<vector<ll>> dp(N, vector<ll>(S + 1, 0));
rep(i, N){
dp[i][0] = 1;
}
rep(i, N){
repd(j, 1, S + 1){
if (j - (N - i) >= 0) dp[i][j] = (dp[i][j] + dp[i][j - (N - i)]) % mod ;
if (i - 1 >= 0) dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
}
}
output(dp[N - 1][S], 0);
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0