結果

問題 No.389 ロジックパズルの組み合わせ
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2016-07-08 23:04:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,297 bytes
コンパイル時間 1,623 ms
コンパイル使用メモリ 165,480 KB
実行使用メモリ 51,532 KB
最終ジャッジ日時 2024-04-21 07:45:02
合計ジャッジ時間 17,881 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
5,376 KB
testcase_02 WA -
testcase_03 AC 2 ms
5,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 52 ms
5,456 KB
testcase_50 AC 5 ms
5,376 KB
testcase_51 AC 4 ms
5,376 KB
testcase_52 AC 12 ms
5,376 KB
testcase_53 AC 7 ms
5,376 KB
testcase_54 AC 13 ms
5,376 KB
testcase_55 AC 2 ms
5,376 KB
testcase_56 AC 6 ms
5,376 KB
testcase_57 AC 24 ms
5,376 KB
testcase_58 AC 43 ms
5,580 KB
testcase_59 AC 34 ms
5,376 KB
testcase_60 AC 16 ms
5,376 KB
testcase_61 AC 69 ms
5,580 KB
testcase_62 AC 17 ms
5,376 KB
testcase_63 AC 45 ms
5,456 KB
testcase_64 AC 13 ms
5,376 KB
testcase_65 AC 9 ms
5,376 KB
testcase_66 AC 14 ms
5,376 KB
testcase_67 AC 14 ms
5,376 KB
testcase_68 AC 15 ms
5,376 KB
testcase_69 WA -
testcase_70 WA -
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 WA -
testcase_75 WA -
testcase_76 WA -
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 WA -
testcase_81 WA -
testcase_82 WA -
testcase_83 WA -
testcase_84 WA -
testcase_85 WA -
testcase_86 WA -
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 WA -
testcase_93 WA -
testcase_94 WA -
testcase_95 WA -
testcase_96 WA -
testcase_97 WA -
testcase_98 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)

typedef long long ll;
ll mo = 1000000007;
//-----------------------------------------------------------------
ll combi(ll N_, ll C_) {
	const int NUM_ = 2000001;
	static ll fact[NUM_ + 1], factr[NUM_ + 1], inv[NUM_ + 1];
	if (fact[0] == 0) {
		inv[1] = fact[0] = factr[0] = 1;
		for (int i = 2; i <= NUM_; ++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
		for (int i = 1; i <= NUM_; ++i) fact[i] = fact[i - 1] * i%mo, factr[i] = factr[i - 1] * inv[i] % mo;
	}
	if (C_<0 || C_>N_) return 0;
	return factr[C_] * fact[N_] % mo*factr[N_ - C_] % mo;
}
//-----------------------------------------------------------------
ll nHk(ll n, ll k)
{
	return combi(n + k - 1, k - 1);
}
//-----------------------------------------------------------------
int M;
vector<int> H;
//-----------------------------------------------------------------
int main() {
	cin >> M;

	int x;
	while(cin >> x) H.push_back(x);

	if (H.size() == 1 && H[0] == 0) {
		printf("1\n");
		return 0;
	}

	int sum = 0;
	rep(i, 0, H.size()) sum += H[i];
	int a = M - sum - (H.size() - 1);
	int b = H.size() + 1;

	if (a < 0) {
		cout << "NA" << endl;
		return 0;
	}

	cout << a << endl;
	cout << b << endl;
	
	ll ans = nHk(a, b);
	cout << ans << endl;
}
0