結果
問題 | No.269 見栄っ張りの募金活動 |
ユーザー |
![]() |
提出日時 | 2015-08-21 23:27:59 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4,216 ms / 5,000 ms |
コード長 | 822 bytes |
コンパイル時間 | 1,516 ms |
コンパイル使用メモリ | 161,328 KB |
実行使用メモリ | 12,160 KB |
最終ジャッジ日時 | 2024-07-16 01:30:42 |
合計ジャッジ時間 | 15,555 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h> using namespace std; string tb1 = "A123456789TJQK"; string tb2 = "DCHS"; bool cmp(string a,string b){ a[0] = 'A'+tb2.find(a[0]); a[1] = 'A'+tb1.find(a[1]); b[0] = 'A'+tb2.find(b[0]); b[1] = 'A'+tb1.find(b[1]); return a < b; } int Klim; int sum[20210] = {}; int dp[110][20110]; int N,S,K; vector<int> v; int dfs(int x,int s){ if( s < 0 ) return 0; if( dp[x][s] != -1 ) return dp[x][s]; if( x == 0 ){ return s == 0; } int ans = 0; for(int i = 0 ; ; i++){ int c = i * x; if( c > s ) break; ans += dfs(x-1,s-c); if( ans >= 1000000007 ) ans -= 1000000007; } return dp[x][s] = ans; } int main(){ memset(dp,-1,sizeof(dp)); cin >> N >> S >> K; S -= K*N*(N-1)/2; cout << dfs(N,S) << endl; }