結果
問題 | No.269 見栄っ張りの募金活動 |
ユーザー |
![]() |
提出日時 | 2015-08-21 23:48:17 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,455 bytes |
コンパイル時間 | 838 ms |
コンパイル使用メモリ | 81,340 KB |
実行使用メモリ | 8,064 KB |
最終ジャッジ日時 | 2024-07-18 12:20:53 |
合計ジャッジ時間 | 2,273 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 1 WA * 14 RE * 7 |
ソースコード
#include <iostream> #include <algorithm> #include <functional> #include <string> #include <climits> #include <vector> #include <numeric> #include <complex> #include <map> #include <bitset> #include <stack> #include <queue> using namespace std; #define __int64 long long #define long __int64 #define REP(i,a,b) for(int i=a;i<b;i++) #define rep(i,n) REP(i,0,n) const int Vecy[4] = {0,-1,0,1}; const int Vecx[4] = {1,0,-1,0}; const int modd = 1000000000 + 7; long comb2_data[1501][751] = {0}; long comb2(int cnt, int n){ //cout << "--" << cnt << "<" << n << "--" << endl; long result; long cnti; if(n == 2){ // cout << (cnt + 2) / 2 << endl; return ((cnt + 2) / 2) % modd; } if(n == 1){ // cout << 1 << endl; return cnt + 1; //cout << "!?" << endl; }else if(cnt == 0){ // cout << 1 << endl; return 1; }else{ if(comb2_data[cnt][n] != 0){ return comb2_data[cnt][n]; } result = 0; cnti = cnt; while(cnti > 0){ result += comb2(cnti, n-1); result %= modd; cnti -= n; } comb2_data[cnt][n] = result; return result; } } int main(){ int n,s,k; int ans = 0; int mind; int test; int cnt; cin >> n >> s >> k; if(k == 0){ k = 1; } mind = (n - 1) * n / 2 * k; cnt = (s - mind) / k; //cout << mind << endl; //cout << cnt << endl; if(cnt < 0){ //cout << 0 << endl; return 0; }else{ ans = 1; //cout << cnt << "," << n << endl; cout << comb2(cnt, n) << endl; } return 0; }