結果

問題 No.287 場合の数
ユーザー krotonkroton
提出日時 2015-10-09 20:26:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 577 bytes
コンパイル時間 398 ms
コンパイル使用メモリ 52,324 KB
実行使用メモリ 7,240 KB
最終ジャッジ日時 2023-08-07 18:49:42
合計ジャッジ時間 1,390 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
7,036 KB
testcase_01 AC 4 ms
7,148 KB
testcase_02 AC 4 ms
7,236 KB
testcase_03 AC 4 ms
7,240 KB
testcase_04 AC 4 ms
6,968 KB
testcase_05 AC 4 ms
7,092 KB
testcase_06 AC 4 ms
7,076 KB
testcase_07 AC 4 ms
7,052 KB
testcase_08 AC 4 ms
7,032 KB
testcase_09 AC 4 ms
6,960 KB
testcase_10 AC 4 ms
7,096 KB
testcase_11 AC 4 ms
7,096 KB
testcase_12 AC 4 ms
7,088 KB
testcase_13 AC 4 ms
7,036 KB
testcase_14 AC 4 ms
6,960 KB
testcase_15 AC 5 ms
7,088 KB
testcase_16 AC 4 ms
7,056 KB
testcase_17 AC 4 ms
7,044 KB
testcase_18 AC 4 ms
7,024 KB
testcase_19 AC 4 ms
7,080 KB
testcase_20 AC 4 ms
7,024 KB
testcase_21 AC 4 ms
7,028 KB
testcase_22 AC 4 ms
7,096 KB
testcase_23 AC 4 ms
7,044 KB
testcase_24 AC 4 ms
7,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
typedef long long ll;

ll C[700][700];

int main(){
	for(int n=0;n<700;n++){
		for(int k=0;k<=n;k++){
			if(k == 0 || k == n){
				C[n][k] = 1;
			} else {
				C[n][k] = C[n-1][k-1] + C[n-1][k];
			}
		}
	}

	int n;
	cin >> n;

	ll res = 0;
	for(int m=0;m<1<<8;m++){
		int tot = 6 * n;
		int cnt = 0;
		for(int i=0;i<8;i++){
			if((m >> i) & 1){
				tot -= n + 1;
				++cnt;
			}
		}
		if(tot < 0){
			continue;
		}
		if(cnt % 2 == 0){
			res += C[tot+7][7];
		} else {
			res -= C[tot+7][7];
		}
	}
	
	cout << res << endl;
	return 0;
}
0