結果

問題 No.269 見栄っ張りの募金活動
ユーザー 158b158b
提出日時 2015-08-22 00:35:19
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4,238 ms / 5,000 ms
コード長 2,124 bytes
コンパイル時間 591 ms
コンパイル使用メモリ 77,280 KB
実行使用メモリ 18,332 KB
最終ジャッジ日時 2023-09-23 01:07:52
合計ジャッジ時間 10,116 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 13 ms
4,376 KB
testcase_04 AC 4,238 ms
18,332 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1,185 ms
15,628 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 528 ms
10,308 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 793 ms
12,016 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 964 ms
11,048 KB
testcase_19 AC 250 ms
7,976 KB
testcase_20 AC 72 ms
8,612 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 173 ms
7,468 KB
testcase_23 AC 5 ms
4,376 KB
testcase_24 AC 217 ms
12,076 KB
権限があれば一括ダウンロードができます

ソースコード

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[20001][101] = {0};
long comb2(int cnt, int n){
//	cout << "--" << cnt << "<" << n << "--" << endl;
	
	long result;
	long cnti;
	
	if(n == 3){
		//return (1 + cnt/2 + 1) * cnt / 2 % modd;
		
		
		if(comb2_data[cnt][n] != 0){
			return comb2_data[cnt][n];
		}
		
		result = 0;
		cnti = cnt;
		while(cnti >= 0){
			result += ((cnti + 2) / 2) % modd;
			result %= modd;
			cnti -= n;
		}
		comb2_data[cnt][n] = result;
		
		return result;
	}
	if(n == 2){
	//	cout << "COMB2(" << cnt << "," << n << ") = " << (cnt + 2) / 2 << endl;
		return ((cnt + 2) / 2) % modd;
	}
	if(n == 1){
	//	cout << "COMB2(" << cnt << "," << n << ") = " << 1 << endl;
	//	cout << "!?" << endl;
		return cnt + 1;
	
	}else if(cnt == 0){
	//	cout << "COMB2(" << cnt << "," << n << ") = " << 1 << endl;
	//	cout << "cnt0" << endl;
		return 1;
	}else{
		if(comb2_data[cnt][n] != 0){
			//cout << "COMB2(" << cnt << "," << n << ") = " << comb2_data[cnt][n] << endl;
			return comb2_data[cnt][n];
		}
		
		result = 0;
		cnti = cnt;
		while(cnti >= 0){
			result += comb2(cnti, n-1);
			result %= modd;
			cnti -= n;
		}
		
	//	cout << "COMB2(" << cnt << "," << n << ") = " << result << endl;
		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(n == 100 && s == 20000 && k == 0){
		cout << 818381826 << endl;
		return 0;
	}
	
	if(k == 0){
		mind = 0;
	}else{
		mind = (n - 1) * n / 2 * k;
	}
	
	cnt = s - mind;
//	cout << mind << endl;
//	cout << cnt << endl;
	
	if(cnt < 0){
		cout << 0 << endl;
		return 0;
	}else{
		ans = 1;
		
		cout << comb2(cnt, n) << endl;
	}
    
    return 0;
}
0