結果

問題 No.269 見栄っ張りの募金活動
ユーザー 158b158b
提出日時 2015-08-21 23:48:17
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,455 bytes
コンパイル時間 649 ms
コンパイル使用メモリ 76,768 KB
実行使用メモリ 7,944 KB
最終ジャッジ日時 2023-09-25 15:37:37
合計ジャッジ時間 2,726 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 RE -
testcase_05 WA -
testcase_06 WA -
testcase_07 RE -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1 ms
4,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 RE -
testcase_14 WA -
testcase_15 RE -
testcase_16 WA -
testcase_17 WA -
testcase_18 RE -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 RE -
testcase_23 WA -
testcase_24 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0