結果
問題 |
No.269 見栄っ張りの募金活動
|
ユーザー |
![]() |
提出日時 | 2020-03-07 14:25:57 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 34 ms / 5,000 ms |
コード長 | 1,071 bytes |
コンパイル時間 | 1,359 ms |
コンパイル使用メモリ | 158,836 KB |
実行使用メモリ | 12,416 KB |
最終ジャッジ日時 | 2024-10-14 13:43:43 |
合計ジャッジ時間 | 2,441 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#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; } }