結果

問題 No.287 場合の数
ユーザー krotonkroton
提出日時 2015-10-10 20:30:32
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 613 bytes
コンパイル時間 428 ms
コンパイル使用メモリ 54,744 KB
実行使用メモリ 7,168 KB
最終ジャッジ日時 2024-04-25 12:32:22
合計ジャッジ時間 1,330 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,168 KB
testcase_01 AC 4 ms
7,168 KB
testcase_02 AC 4 ms
7,040 KB
testcase_03 AC 4 ms
7,040 KB
testcase_04 AC 4 ms
7,040 KB
testcase_05 AC 4 ms
7,040 KB
testcase_06 AC 4 ms
7,040 KB
testcase_07 AC 4 ms
6,912 KB
testcase_08 AC 4 ms
7,040 KB
testcase_09 AC 4 ms
7,040 KB
testcase_10 AC 4 ms
6,912 KB
testcase_11 AC 4 ms
7,040 KB
testcase_12 AC 4 ms
7,040 KB
testcase_13 AC 4 ms
7,168 KB
testcase_14 AC 4 ms
7,168 KB
testcase_15 AC 4 ms
7,168 KB
testcase_16 AC 4 ms
7,040 KB
testcase_17 AC 4 ms
7,040 KB
testcase_18 AC 4 ms
7,040 KB
testcase_19 AC 4 ms
7,168 KB
testcase_20 AC 4 ms
7,040 KB
testcase_21 AC 4 ms
7,168 KB
testcase_22 AC 4 ms
7,040 KB
testcase_23 AC 5 ms
7,168 KB
testcase_24 AC 4 ms
7,040 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 cnt=0;cnt<=8;cnt++){
		int tot = 6 * n - (n + 1) * cnt;
		if(tot < 0){
			break;
		}
		if(cnt % 2 == 0){
			res += C[8][cnt] * C[tot+7][7];
		} else {
			res -= C[8][cnt] * C[tot+7][7];
		}
    }
    
    cout << res << endl;
    return 0;
}
0