結果

問題 No.287 場合の数
ユーザー antaanta
提出日時 2015-10-09 22:26:27
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 1,831 bytes
コンパイル時間 563 ms
コンパイル使用メモリ 75,440 KB
実行使用メモリ 10,656 KB
最終ジャッジ日時 2023-08-07 18:52:39
合計ジャッジ時間 1,601 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
10,492 KB
testcase_01 AC 4 ms
10,380 KB
testcase_02 AC 5 ms
10,376 KB
testcase_03 AC 5 ms
10,416 KB
testcase_04 AC 5 ms
10,396 KB
testcase_05 AC 5 ms
10,468 KB
testcase_06 AC 4 ms
10,472 KB
testcase_07 AC 5 ms
10,448 KB
testcase_08 AC 5 ms
10,504 KB
testcase_09 AC 4 ms
10,460 KB
testcase_10 AC 5 ms
10,512 KB
testcase_11 AC 4 ms
10,436 KB
testcase_12 AC 4 ms
10,432 KB
testcase_13 AC 4 ms
10,540 KB
testcase_14 AC 5 ms
10,452 KB
testcase_15 AC 5 ms
10,468 KB
testcase_16 AC 5 ms
10,456 KB
testcase_17 AC 4 ms
10,392 KB
testcase_18 AC 5 ms
10,392 KB
testcase_19 AC 4 ms
10,656 KB
testcase_20 AC 5 ms
10,448 KB
testcase_21 AC 5 ms
10,464 KB
testcase_22 AC 4 ms
10,412 KB
testcase_23 AC 5 ms
10,364 KB
testcase_24 AC 4 ms
10,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

unsigned long long C[1000+1][1000+1];

unsigned long long rnomial(int r, int n, int k) {
	if(r == 0) return n == 0 && k == 0 ? 1 : 0;
	if(k == 0) return 1;
	if(n == 0) return 0;
	unsigned long long sum = 0;
	int imax = k/r;
	if(imax > n) return 0;
	rer(i, 0, imax) {
		unsigned long long t = C[n][i] * C[n+k-1-r*i][n-1];
		if(i % 2 == 0) sum += t; else sum -= t;
	}
	return sum;
}

int main() {
	const int Combination_N = 1000;
	for(int i = 0; i <= Combination_N; i ++) {
		C[i][0] = 1;
		for(int j = 1; j <= i; j ++)
			C[i][j] = C[i-1][j-1] + C[i-1][j];
	}
	int n;
	while(cin >> n) {
		ll ans = rnomial(n+1, 8, 6 * n);
		cout << ans << endl;
	}
	return 0;
}
0